I am new to PHP/MySQL, and google isn't being especially helpful with this.
I have a form that I am working on where the user can update information stored in a database. When the click "update" the form should reload with the new values in place. It loads properly the first time, displaying old information. It updates the information in the database. However, when the page reloads, the fields that were just updated are now all blank.
<?php
$query = "SELECT * FROM userList
WHERE status = 1 AND name = '$userName'";
$result = mysql_query($query);
$user = mysql_fetch_array ($result, MYSQL_ASSOC);
?>
<p class = "other"> Start with the basics: </p>
<fieldset class = "paged"> <legend>Basics</legend>
<form class = "centered"
method = "post"
action = "">
<label for = "uName">Name:</label>
<input class = "login"
type = "text"
size = "30"
name = "uName"
<?php
print "value = '".$user['name']."'>";
?>
</input><br /> <br />
<label for = "address">Address:</label>
<input class= "login"
type = "text"
name = "address"
<?php
print "value = '".$user['address']."'>";
?>
</input><br /> <br />
<input class= "ok"
type = "image"
src = "images/update.png"
value = "submit"
name = "submit"
alt = "submit">
</input>
</form>
<?php
$address = mysql_real_escape_string (filter_input(INPUT_POST,"address"));
$name = $user['name'];
$query = "UPDATE userList
SET address = '$address',
WHERE name = '$name' AND status = 1";
mysql_query($query);
mysql_close ();
?>
There is quite a bit more to the form (mostly more of the same), but this should illustrate the logic.
I want the user to be able to pull up the current information. The user should be able to update selected fields, click update, and have the page show the new information.
Instead, the information updates, but then loads blanks into the fields instead of the new data. If they go back to the beginning and reload the page, it shows the updated values. If they accidentally click update twice, it loads a blank into the address.