Hiya i've created a page that is ment to click on a name then all info comes up in my browser in a form .. this all works fine .. I then want to be able to change the values in the form and update the record .. this does not work and i can't see why not .. below is my code for the page
thanks for any help
Peter
<head>
<title>Mysql Insert Test3</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?
$db = mysql_connect("localhost","root","password");
mysql_select_db("rentdb",$db);
if ($id) {
if ($submit) {
$sql = "UPDATE users SET real_name='$real_name',user='$user',pass='$pass',email='$email' ";
$result = mysql_query($sql);
echo "Thank you information updated.\n";
} else {
// query the db
$sql = "SELECT * FROM users WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form name="tute6" method="post" action="<? echo $PHP_SELF ?>">
<input type="hidden" name="is" value=http://www.phpbuilder.com/board/archive/index.php/"<? echo $myrow["id"] ?>">
Real Name:<input type="text" name="real_name" value="<? echo $myrow["real_name"] ?>"><br>
User Name:<input type="text" name="user" value="<? echo $myrow["user"] ?>" ><br>
Password:<input type="text" name="pass" value="<? echo $myrow["pass"] ?>"><br>
Email:<input type="text" name="email" value="<? echo $myrow["email"] ?>"><br>
<input type="submit" name="Submit" value="Enter Information">
</form>
<?
}
} else {
// Display list of users
$result = mysql_query("SELECT * FROM users",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href=\"%s?id=%s\">%s %s</a><br>\n", $PHP_SELF, $myrow["id"], $myrow["real_name"], $myrow["email"]);
}
}
?>
</body>
thanks for any help
Peter
<head>
<title>Mysql Insert Test3</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?
$db = mysql_connect("localhost","root","password");
mysql_select_db("rentdb",$db);
if ($id) {
if ($submit) {
$sql = "UPDATE users SET real_name='$real_name',user='$user',pass='$pass',email='$email' ";
$result = mysql_query($sql);
echo "Thank you information updated.\n";
} else {
// query the db
$sql = "SELECT * FROM users WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form name="tute6" method="post" action="<? echo $PHP_SELF ?>">
<input type="hidden" name="is" value=http://www.phpbuilder.com/board/archive/index.php/"<? echo $myrow["id"] ?>">
Real Name:<input type="text" name="real_name" value="<? echo $myrow["real_name"] ?>"><br>
User Name:<input type="text" name="user" value="<? echo $myrow["user"] ?>" ><br>
Password:<input type="text" name="pass" value="<? echo $myrow["pass"] ?>"><br>
Email:<input type="text" name="email" value="<? echo $myrow["email"] ?>"><br>
<input type="submit" name="Submit" value="Enter Information">
</form>
<?
}
} else {
// Display list of users
$result = mysql_query("SELECT * FROM users",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href=\"%s?id=%s\">%s %s</a><br>\n", $PHP_SELF, $myrow["id"], $myrow["real_name"], $myrow["email"]);
}
}
?>
</body>