Forum Moderators: coopster
I think the code im having trouble with is:
mysql_query("update example set name='$name', age='$age' where id='$id'");
// PHP update script
mysql_connect("localhost", "root", "root") or die(mysql_error());
mysql_select_db("pet") or die(mysql_error());;
if($_POST['Submit']){
$name=$_POST['name'];
$age=$_POST['age'];
mysql_query("update example set name='$name', age='$age' where id='$id'");
header("location:select.php");
exit;
}
// END PHP update script
The form and script are on the same page:
<form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>">
ID: <? echo $row['id']; ?><br />
Name :
<input name="name" type="text" id="name" value="<? echo $row['name']; ?>"/>
Age :
<input name="age" type="text" id="age" value="<? echo $row['age']; ?>"/>
<input type="submit" name="Submit" value="Submit" />
</form>