newbie12345 Posted May 15, 2010 Share Posted May 15, 2010 im trying to update the user account but for some reason its not updating can any one help me with my code. this is my code or is there another way i can accomplish this i was getting a error Notice: Undefined variable: users in C:\wamp\www\music website1\updateaccount.php on line 8 Notice: Undefined variable: users in C:\wamp\www\music website1\updateaccount.php on line 21 <?php session_start(); include ('connect.php'); if (isset($_POST["submit"])){ $_SESSION['u_name']=$users; $user = $_POST['u_name']; $first =$_POST['f_name']; $last = $_POST['l_name']; $birth = $_POST['DOB']; $sex = $_POST['gender']; $addres = $_POST['address']; $pass = $_POST['pwd']; $conpass = $_POST['pwd1']; $eaddress =$_POST['e_address']; $sql= ("UPDATE user_accounts SET username = '$user', firstname = '$first', lastname = '$last', birthday = '$birth', gender = '$sex', address = '$addres', password = '$pass', confirm_password = '$conpass', email_address = '$eaddress' WHERE user_id = '$users'"); $rest = mysql_query($sql); if ($rest){ echo "Your account have successfully been updated"; }ELSE{ echo "There was an error updating ur account.<br>Please contact site admin"; } } ?> Link to comment https://forums.phpfreaks.com/topic/201829-help-help-due-today/ Share on other sites More sharing options...
trq Posted May 15, 2010 Share Posted May 15, 2010 As the error suggests, $users isn't defined anywhere in your code. Link to comment https://forums.phpfreaks.com/topic/201829-help-help-due-today/#findComment-1058627 Share on other sites More sharing options...
newbie12345 Posted May 15, 2010 Author Share Posted May 15, 2010 i solved that problem but its not updating in the database <?php session_start(); include ('connect.php'); if (isset($_POST["submit"])){ $users= $_SESSION['u_name']; $user = $_POST['u_name']; $first =$_POST['f_name']; $last = $_POST['l_name']; $birth = $_POST['DOB']; $sex = $_POST['gender']; $addres = $_POST['address']; $pass = $_POST['pwd']; $conpass = $_POST['pwd1']; $eaddress =$_POST['e_address']; $sql= ("UPDATE user_accounts SET username = '$user', firstname = '$first', lastname = '$last', birthday = '$birth', gender = '$sex', address = '$addres', password = '$pass', confirm_password = '$conpass', email_address = '$eaddress' WHERE user_id = '$users'"); $rest = mysql_query($sql); if ($rest){ echo "Your account have successfully been updated"; }ELSE{ echo "There was an error updating ur account.<br>Please contact site admin"; } } ?> Link to comment https://forums.phpfreaks.com/topic/201829-help-help-due-today/#findComment-1058631 Share on other sites More sharing options...
trq Posted May 15, 2010 Share Posted May 15, 2010 Instead of your custom error message, lets see what mysql has to say. if ($rest) { echo "Your account have successfully been updated"; } else { echo mysql_error() . "<br />$sql"; } } Link to comment https://forums.phpfreaks.com/topic/201829-help-help-due-today/#findComment-1058634 Share on other sites More sharing options...
newbie12345 Posted May 15, 2010 Author Share Posted May 15, 2010 did that but for some reason its not updating Link to comment https://forums.phpfreaks.com/topic/201829-help-help-due-today/#findComment-1058640 Share on other sites More sharing options...
trq Posted May 15, 2010 Share Posted May 15, 2010 What error are you now seeing? Link to comment https://forums.phpfreaks.com/topic/201829-help-help-due-today/#findComment-1058664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.