Jump to content

[SOLVED] Data not Updating


stuart7398

Recommended Posts

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 <>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.