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
https://forums.phpfreaks.com/topic/100321-solved-data-not-updating/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.