navybofus Posted May 7, 2010 Share Posted May 7, 2010 changepass.php include 'db.php'; $id = $_GET['id']; $new_password = $_POST['new_password']; $old_password = $_POST['old_password']; $old_password = md5($old_password); $new_password = md5($new_password); $sql = mysql_query("SELECT * FROM users WHERE password='$old_password' AND userid='$id'"); $change_check = mysql_num_rows($sql); if ($change_check > 0) { mysql_query("UPDATE users SET password='$new_password' WHERE userid='$id'"); echo "Your password has been changed!"; header ("Location: login_success.php?id=$id"); } else { echo "Your old password password was not correct please try agian.; include 'login_success.php'; } I realize that this probably isn't the best way to go about changing a password for an account but I am mostly just experimenting. I want to actually learn PHP instead of just copy + paste this and that. So I made my own script and I am getting an Unexpected $end. It identifies the last line of the script which is the closing php tag ?> I think it has something to do with my IF Statement so I'll be looking it over but if anyone catches a bug please let me know. Thanks. Link to comment https://forums.phpfreaks.com/topic/201039-broken-change-password-script/ Share on other sites More sharing options...
navybofus Posted May 7, 2010 Author Share Posted May 7, 2010 found it! I looked and saw a RED include lol. I forgot a dang ". Thanks for those who looked. Of course now I am having another problem. I may have to ask about it after some testing. Link to comment https://forums.phpfreaks.com/topic/201039-broken-change-password-script/#findComment-1054759 Share on other sites More sharing options...
tartou2 Posted May 7, 2010 Share Posted May 7, 2010 This is the corrected code. Copy/pasted and it will work perfectly include 'db.php'; $id = $_GET['id']; $new_password = $_POST['new_password']; $old_password = $_POST['old_password']; $old_password = md5($old_password); $new_password = md5($new_password); $sql = mysql_query("SELECT * FROM users WHERE password='$old_password' AND userid='$id'"); $change_check = mysql_num_rows($sql); if ($change_check > 0) { mysql_query("UPDATE users SET password='$new_password' WHERE userid='$id'"); echo "Your password has been changed!"; header ("Location: login_success.php?id=$id"); } else { echo "Your old password password was not correct please try agian."; include 'login_success.php'; } Link to comment https://forums.phpfreaks.com/topic/201039-broken-change-password-script/#findComment-1054760 Share on other sites More sharing options...
tartou2 Posted May 7, 2010 Share Posted May 7, 2010 found it! I looked and saw a RED include lol. I forgot a dang ". Thanks for those who looked. Of course now I am having another problem. I may have to ask about it after some testing. lol you were faster then me Link to comment https://forums.phpfreaks.com/topic/201039-broken-change-password-script/#findComment-1054762 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.