Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2010
    Posts
    79
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Problem with PHP password changer

    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:

    PHP 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
    Last edited by authorandrew; 11-09-2011 at 02:56 PM. Reason: Removed code

  • #2
    Regular Coder
    Join Date
    Oct 2009
    Location
    United States
    Posts
    157
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Hello there.


    PHP Code:
    $password mysqli_real_escape_string($dbctrim($_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.
    Adobe Dreamweaver shall be destroyed!

  • #3
    New Coder
    Join Date
    May 2010
    Posts
    79
    Thanks
    8
    Thanked 0 Times in 0 Posts
    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

  • #4
    Regular Coder
    Join Date
    Oct 2009
    Location
    United States
    Posts
    157
    Thanks
    8
    Thanked 4 Times in 4 Posts
    haha, no problem. Those things happen all the time. lol
    Adobe Dreamweaver shall be destroyed!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •