...

View Full Version : Problem with PHP password changer



authorandrew
11-09-2011, 02:40 PM
Hi all,
I'm working on a project which requires a password changer. In other words, if the user is logged in, to allow them to set a new username/password. Here is my code:


CODE REMOVED

Apparently the problem is in the else/if statements, but I can't figure out why, as the equality operators should be working. Instead, when I enter in two passwords, it displays as not matching, every time.

The username bit works perfectly. It's the password I'm having trouble with. Because it's not matching for some reason, it's also not updating in the database. What am I doing wrong?

Thanks,
Andrew

votter
11-09-2011, 02:48 PM
Hello there. :)




$password = mysqli_real_escape_string($dbc, trim($_POST['password']));


Is the variable you have set for the first password, but you are comparing $password1 to $password2 in the if statements, in which $password1 does not exist. Just a variable naming issue I see. Try fixing that and see if it works.

authorandrew
11-09-2011, 02:56 PM
Oh my...
Here is where I slap myself on the face and look really stupid. Thanks for catching that, votter! I had been using a password1 variable and then switched it out for various reasons; but I should have double-checked my code. Works perfectly now.

I'm going to remove the code from the original thread as I would prefer it not to be public on the internet in its entirety.

Andrew

votter
11-09-2011, 02:59 PM
haha, no problem. Those things happen all the time. lol



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum