Brief synopsis: When I select a user from a dropdown (which populates from Users table), I want the resulting page to show the specific details for that user in a form based view with the current values already filled in based on current data in my database. Database Values are not appearing, instead showing $current_userlastname
on the page. Code below:
if ($dbConnected) {
$UserID = $_POST['UserID'];
$sql = "SELECT * FROM Users WHERE ID = '$UserID'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$current_userlastname = $row['User_LastName'];
$current_userfirstname = $row['User_FirstName'];
$current_useremail = $row['User_Email'];
$current_username = $row['UserName'];
$current_userpassword = $row['UserPassword'];
}
echo '<h2 style = "font-family: arial,helvetica,sans-serif;"> User EDIT </h2>';
echo '<form name="postUser" action="UserUpdate.php" method="POST">';
echo '<input type="hidden" name="UserID" value=".$UserID."/>';
echo '
<table>
<tr>
<td>Last Name</td>
<td><input type="text" name="User_LastName" value="$current_userlastname" /></td>
</tr>
<tr>
<td>First Name</td>
<td><input type="text" name="User_FirstName" value="$current_userfirstname" /></td>
</tr>
<tr>
<td>Email Address</td>
<td><input type="text" name="User_Email" value="$current_useremail" /></td>
</tr>
<tr>
<td>Username</td>
<td><input type="text" name="UserName" value="$current_username" /></td>
</tr>
<tr>
<td>User Password</td>
<td><input type="text" name="UserPassword" value="$current_userpassword" /></td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" value="save" /></td>
</tr>
</table>
';
echo '</form>';