stuart7398 Posted April 9, 2008 Share Posted April 9, 2008 Hi. I'm trying to add the 'id' number to this 'UPDATE' form. It doesn't work as I assume mysql thinks it's updating. What do I use to enter the 'id' number or other data for that matter? AND Can if anyone spots faults / security issues or ways to reduce the code, which would be helpful. Examples / suggestions / code all appreciated Thanks, Stuart. $username = "$SESS_MEMBER_ID"; if(isset($_POST['save'])){ $firstname = mysql_real_escape_string($_POST['firstname']); $mobile = mysql_real_escape_string($_POST['mobile']); $phone_2 = mysql_real_escape_string($_POST['phone_2']); $login = mysql_real_escape_string($_POST['login']); mysql_query("UPDATE members SET firstname='$firstname', mobile='$mobile', phone_2='$phone_2', login='$login' WHERE member_id = '$SESS_MEMBER_ID'"); } [b]Print "<div class='account'>"; Print "<br /><h3>My Account</h3>"; Print "Account Number:<span class='my_account'> ".$info['member_id']."</span>";[/b] list($firstname, $mobile, $phone_2, $login) = mysql_fetch_array(mysql_query("SELECT firstname, mobile, phone_2, login FROM members WHERE member_id = '$SESS_MEMBER_ID'")); Print "<div class='account'>"; Print '<br /><h3>Update Account</h3>'; Print "<h3>Personal Details</h3>"; Print '<form method="post" action="">'; Print '<p>First Name <span class="my_account"><input type="text" name="firstname" size="24" value="'.$firstname.'" /></span></p>'; Print '<p>Mobile <span class="my_account"><input type="text" name="mobile" size="24" value="'.$mobile.'" /></span></p>'; Print '<p>Phone 2 <span class="my_account"><input type="text" name="phone_2" size="24" value="'.$phone_2.'" /></span></p>'; Print '<p>Login <span class="my_account"><input type="text" name="login" size="24" value="'.$login.'" /></span></p>'; Print '<p> <input type="submit" value="Update" name="save" /></p>'; Print '</form></div>'; Print ' '.$firstname.' '.$mobile.' '.$login.' '.$phone_2.' '; ?> --fenway edit: really, use code blocks!!! Quote Link to comment Share on other sites More sharing options...
rhodesa Posted April 9, 2008 Share Posted April 9, 2008 First, this line is not needed, because you don't use it: $username = "$SESS_MEMBER_ID"; Change this: mysql_query("UPDATE members SET firstname='$firstname', mobile='$mobile', phone_2='$phone_2', login='$login' WHERE member_id = '$SESS_MEMBER_ID'"); to this: mysql_query("UPDATE members SET firstname='$firstname', mobile='$mobile', phone_2='$phone_2', login='$login' WHERE member_id = '$SESS_MEMBER_ID'") or die("Update error: ".mysql_error()); and it should provide you info on why it's not updating. Quote Link to comment Share on other sites More sharing options...
stuart7398 Posted April 9, 2008 Author Share Posted April 9, 2008 Hi. Thanks for you input. I'm not looking to update the 'id' number, i'm looking to display it. thanks. Update Account Account Number: user account id number Personal Details First Name update field Mobile update field Phone 2 update field Address update field Quote Link to comment Share on other sites More sharing options...
rhodesa Posted April 9, 2008 Share Posted April 9, 2008 Ah, try this: <?php if(isset($_POST['save'])){ $firstname = mysql_real_escape_string($_POST['firstname']); $mobile = mysql_real_escape_string($_POST['mobile']); $phone_2 = mysql_real_escape_string($_POST['phone_2']); $login = mysql_real_escape_string($_POST['login']); mysql_query("UPDATE members SET firstname='$firstname', mobile='$mobile', phone_2='$phone_2', login='$login' WHERE member_id = '$SESS_MEMBER_ID'") or die("Update error: ".mysql_error()); } list($member_id,$firstname, $mobile, $phone_2, $login) = mysql_fetch_array(mysql_query("SELECT member_id, firstname, mobile, phone_2, login FROM members WHERE member_id = '$SESS_MEMBER_ID'")); print "<div class='account'>"; print "<h3>My Account</h3>"; print "Account Number:<span class='my_account'> ".$member_id."</span>"; print "<div class='account'>"; print '<h3>Update Account</h3>'; print "<h3>Personal Details</h3>"; print '<form method="post" action="">'; print '<p>First Name <span class="my_account"><input type="text" name="firstname" size="24" value="'.$firstname.'" /></span></p>'; print '<p>Mobile <span class="my_account"><input type="text" name="mobile" size="24" value="'.$mobile.'" /></span></p>'; print '<p>Phone 2 <span class="my_account"><input type="text" name="phone_2" size="24" value="'.$phone_2.'" /></span></p>'; print '<p>Login <span class="my_account"><input type="text" name="login" size="24" value="'.$login.'" /></span></p>'; print '<p> <input type="submit" value="Update" name="save" /></p>'; print '</form></div>'; ?> Quote Link to comment Share on other sites More sharing options...
stuart7398 Posted April 10, 2008 Author Share Posted April 10, 2008 thanks Quote Link to comment Share on other sites More sharing options...
stuart7398 Posted April 10, 2008 Author Share Posted April 10, 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.