Hiya all.
I am trying to build a form that allows users to update their details held in the database. I've gone for the approach of having the fields already stating what is in the database, but I have now come across another problem. When i click update it just reverts back to the original data in the database becuase its calling the variable which holds the data. What variable should i put in the mysql query instead?
Thanks
I am trying to build a form that allows users to update their details held in the database. I've gone for the approach of having the fields already stating what is in the database, but I have now come across another problem. When i click update it just reverts back to the original data in the database becuase its calling the variable which holds the data. What variable should i put in the mysql query instead?
Thanks
Code:
<?php include ('connect.php'); mysql_select_db("a6188092") or die(mysql_error()); $members = mysql_query(sprintf("SELECT * FROM Member WHERE loginName='%s'", mysql_real_escape_string(trim($_COOKIE['loginName'])))) or die ('SQL Error: ' . mysql_error()); $fetch = mysql_fetch_array($members); $loginName = $fetch['loginName']; echo 'New user name: <input type="text" size="20" maxlength="15" name="userName" value="'.$loginName.'" />'; echo "<br />"; if ($_POST['edit'] == 'Update your account') { $query = mysql_query(sprintf("UPDATE Member SET loginName='$loginName' WHERE loginName='%s'", mysql_real_escape_string(trim($_COOKIE['loginName'])))) or die ('SQL Error: ' . mysql_error()); echo("Details updated. <br /><br /><br />"); } ?>
Comment