I encountered a problem while implementing my extra feature "Change Password". In the "changepassword_form", it asks for the old password and compares it with the 'hash' in the 'users' table to check whether user has entered correct old password. I used something like

if(crypt($_POST["old"]) == $hash)
    // some code
    apologize("Passwords don't match!");

Even if I type the right password, the else statement gets executed. What's wrong with the code above?

  • You can answer your own question and accept the answer in a separate post!
    – kzidane
    Commented Aug 3, 2014 at 10:38

1 Answer 1


For comparison, crypt function is used in a slightly different way. It accepts 2 arguments.

if ( (crypt(str $user_input, $password_hash) == $password_hash)  
    echo("Password Verified");  

You can go to this link for a better understanding! (Or refer to login.php in public directory of pset7)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .