The following code is what I've used to encrypt a password in PHP...
$password = sha1(sha1($_POST['password']).sha1("mySalt@$#(%"));
What code can I use so users can log in using what they typed?
The following code is what I've used to encrypt a password in PHP...
$password = sha1(sha1($_POST['password']).sha1("mySalt@$#(%"));
What code can I use so users can log in using what they typed?
sha1
is a hashing algorithm, not a 2-way encryption. You cannot retrieve the original password.
You should use crypt for password hashing, sha1/md5 are too weak.
All you need:
function check_password($password) {
...//get db password to compare
if (crypt($post_password, $db_results[0]['password']) == $db_results[0]['password']) {
return true;
} else { return false; }
}