php mysql update problem
Posted: Mon Feb 07, 2011 3:50 am
I'm stuck. I've followed a couple tutorials on how to update a mysql database via php form, and I'm getting there, but I just can't seem to get past this. First let me say I'm sorry this is so basic, and I hope it's ok that I'm posting here. I'm not even to the point of getting "user_updated.php" working. Everything seems to ok, except the text box value is always " ". The user_id is passing (from the previous page) just fine, but the user_name isn't passing anything. This is what I have. Any help that anyone can offer is much appreciated!!!!
Code: Select all
<?php
$con =mysql_connect("localhost","myname","");
if (!$con)
{die('could not connect: ' . mysql_error());
}
$user_id=$_GET['user_id'];
mysql_select_db("test", $con);
$result = mysql_query("SELECT * FROM sb_users WHERE user_id='$user_id'");
while ($row = mysql_fetch_array($result))
{
echo $row['user_name'] . "";
echo "<br/>";
?>
<form action="user_updated.php" method="post">
<input type="hidden" name="user_id" value="<? echo $user_id; ?>">
Name: <input type="text" name="user_name" value="<? echo $user_name; ?>"><br>
<input type="Submit" value="Update">
</form>
<?php
}
?>