I have a form in account.php that is prefilled with the user's current info but can be changed and then when you submit, it updates the database. However, when returned to the page after the update, the prefilled text is not updated. It only updates if you re-log in. At this point I have only messed with updating the username.
ACCOUNT.PHP
<div id="main_middle">
<h1>
</h1>
<h1>MANAGE YOUR ACCOUNT INFORMATION</h1>
<p> </p>
username :
<form method="post" action="update_check.php">
<input type="text" name="username" value="<?php echo "".$_SESSION['username'].""; ?>" size="40" />
<input name="update data" type="submit" id="update data2" value="save changes"/>
</form>
<br />
<p> </p>
email:<br />
<form method="post" action="update_check.php">
<input name="email" type="text" id="email" value="<?php echo "".$_SESSION['email'].""; ?>" size="40" />
<input name="update data" type="submit" id="update data" value="save changes"/>
<br />
<br />
<br />
<input name="reset" type="reset" id="reset" value="reset form"/>
</form>
</div>
I have set up the username session variable to update if the database updates, however, it does not seem to be working correctly. Any suggestions?
UPDATE_CHECK.PHP
<?php
include("db_config.php");
$tbl_name="usernames"; // Table name
// username and password sent from form
$username=$_POST['username'];
$username = stripslashes($username);
$username = mysql_real_escape_string($username);
$username = $_POST['username'];
$checkformembers = mysql_query("SELECT * FROM email_confirm WHERE username = '$username'");
if(mysql_num_rows($checkformembers) != 0){
header("location:sign_up_usererror.php");
die();
}
$username = $_POST['username'];
$checkformembers = mysql_query("SELECT * FROM usernames WHERE username = '$username'");
if(mysql_num_rows($checkformembers) != 0){
header("location:sign_up_usererror.php");
die();
}
$result = mysql_query("UPDATE usernames SET username = '$username'");
if($result) {
$_SESSION['username'] = $_POST['username'];
header("location:account.php");
die();
}
?>