1

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
}
else
{
    apologize("Passwords don't match!");
}

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

1
  • You can answer your own question and accept the answer in a separate post! – kzidane Aug 3 '14 at 10:38
2

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)

php.net/manual/en/function.crypt.php

You must log in to answer this question.

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