更新页面:
<?php
mysql_connect("localhost","root","");//database connection
mysql_select_db("basic");
$data_id = $_GET['id'];
$order = "select * from user where id=$data_id"; $result=mysql_query($order);
while($row = mysql_fetch_array($result) )
{
$fn= $row['First_name'] ; $ln= $row['last_name'] ; $s= $row['sex'] ; $ad= $row['address']; }
?> <form action="form_finalupdate.php" method="GET" >
<fieldset> <legend>Welcome <?php echo "$fn" ?></legend>
Update your Information:<br><br>
First Name: <input type="text" name="fname" value="<?php echo "$fn"
?>" > Last Name: <input type="text" name ="lname"
value="<?php echo "$ln" ?>" > <br><br>
Sex:<br> <input type="radio" name="sex" value="male" value="<?php echo
"$s"?>" >Male<br> <input type="radio" name="sex" value="female"
value="<?php echo "$s" ?>" >Female<br><br>
Address: <input type=text name="add"value="<?php echo "$ad" ?>" >
<br><br>
<input type="submit" value="Update" >
</fieldset> </form>
Finalupdate页面:
<?php
mysql_connect("localhost","root","");//database connection
mysql_select_db("basic");
$data_id = $_GET['id'];
$fn= $row['First_name'] ; $ln= $row['last_name'] ; $s= $row['sex'] ; $ad= $row['address'];
$order = "UPDATE user
SET First_name='$fn',last_name='$ln',sex='$s',address='$ad'
WHERE id='$data_id' ";
$result=mysql_query($order); ?>
答案 0 :(得分:-1)
$ data_id = $ _GET ['id'];
$ fn = $ row ['First_name']; $ ln = $ row ['last_name']; $ S = $ row ['sex']; $ ad = $ row ['address'];
你在“form_finalupdate.php”中没有任何“$ row”变量。请尝试$ _GET。
P.S:直接将数据传递给查询可以导致SQL注入。请使用纠正措施或使用PDO。