Gruzin Posted September 14, 2006 Share Posted September 14, 2006 Hi guys, please check this script, if it won't take u long and tell me what am I doing wrong?Actually, I want the password to be updated... Script gives NO error just doesn't update db. any help will be greatly appreciated. Thank you.[code]<?phprequire ("config.php");$query = "SELECT * FROM sec";$result = mysql_query($query) or die("Error: " . mysql_error());while($row = mysql_fetch_array($result))$db_pass = $row['pass']; // password from db?><?php$pass = $_POST['pass']; // old password$pass2 = $_POST['pass2']; // new pass 1$pass3 = $_POST['pass3']; // new pass2 - confirmif($pass != $db_pass){ echo "Old Password is incorrect"; exit(); }else if($pass2 != $pass3){ echo "New Passwords didn't match"; exit(); }else if(empty($pass2)){ echo "Please enter the new password"; exit(); }else{$update = "UPDATE sec SET pass = '$pass2'";if(!$update){ die('Could not update: '.mysql_error()); }header ('location: edit_pass.php');}?>[/code] Link to comment https://forums.phpfreaks.com/topic/20736-problem-with-update-solved/ Share on other sites More sharing options...
hostfreak Posted September 14, 2006 Share Posted September 14, 2006 Try:[code]<?phprequire ("config.php");$query = "SELECT * FROM sec";$result = mysql_query($query) or die("Error: " . mysql_error());while($row = mysql_fetch_array($result))$db_pass = $row['pass']; // password from db?><?php$pass = $_POST['pass']; // old password$pass2 = $_POST['pass2']; // new pass 1$pass3 = $_POST['pass3']; // new pass2 - confirmif($pass != $db_pass){ echo "Old Password is incorrect"; exit(); }else if($pass2 != $pass3){ echo "New Passwords didn't match"; exit(); }else if(empty($pass2)){ echo "Please enter the new password"; exit(); }else{$update = "UPDATE sec SET pass = '$pass2'";$result = mysql_query($update);if(!$result){ die('Could not update: '.mysql_error()); } else {header ('location: edit_pass.php');}}?>[/code] Link to comment https://forums.phpfreaks.com/topic/20736-problem-with-update-solved/#findComment-91776 Share on other sites More sharing options...
Gruzin Posted September 14, 2006 Author Share Posted September 14, 2006 GOD, that query is killing me! Hostfreak, Thanks freind :) Link to comment https://forums.phpfreaks.com/topic/20736-problem-with-update-solved/#findComment-91777 Share on other sites More sharing options...
hostfreak Posted September 14, 2006 Share Posted September 14, 2006 No problem buddy, glad I could help. Link to comment https://forums.phpfreaks.com/topic/20736-problem-with-update-solved/#findComment-91778 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.