stuart7398 Posted April 9, 2008 Share Posted April 9, 2008 Hi. I'm learning how to update mysql data using a form. I'm not sure if I am sending the form to the correct location. I'm currently learning this mysql through trail and error, however I can no longer sit here for 20 hours figuring out something minor. Code / suggestions / examples / corrections appreciated. Thanks, Stuart. This is where users come to update their details <?php require '../conn/config.php'; require '../conn/opendb.php'; $username = "$SESS_MEMBER_ID"; if(isset($_POST['save'])){ $firstname = mysql_real_escape_string($_POST['firstname']); $pin = mysql_real_escape_string($_POST['pin']); mysql_query("UPDATE members SET firstname='$firstname', pin='$pin' WHERE username='$username'"); } list($firstname, $pin) = mysql_fetch_array(mysql_query("SELECT firstname FROM members WHERE member_id = '$SESS_MEMBER_ID'")); echo ' <form method="post" action="members/acc-updated.php"> <p>First Name <input type="text" name="firstname" size="24" value="'.$firstname.'" /></p> <p>pin <input type="text" name="pin" size="24" value="'.$pin.'" /></p> <p> <input type="submit" value="save data" name="save" /> </p> </form> '; ?> This is where I have sent the above form to, but no data is showing at all, or as updated ?php require '../conn/config.php'; require '../conn/opendb.php'; $username = "$SESS_MEMBER_ID"; if(isset($_POST['save'])){ $firstname = mysql_real_escape_string($_POST['firstname']); $pin = mysql_real_escape_string($_POST['pin']); mysql_query("SELECT members SET firstname='$firstname', pin='$pin' WHERE username='$username'"); } list($firstname, $pin) = mysql_fetch_array(mysql_query("SELECT firstname FROM members WHERE member_id = '$SESS_MEMBER_ID'")); echo ' <p>account updated</p> '; ?> --fenway: code blocks are wrapped in square brackets, not <> Quote Link to comment Share on other sites More sharing options...
fenway Posted April 9, 2008 Share Posted April 9, 2008 Well, do you get into that isset() if statement? Did you echo the query string? Quote Link to comment Share on other sites More sharing options...
stuart7398 Posted April 9, 2008 Author Share Posted April 9, 2008 Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.