Another issue with sha1.
I am creating users via a registration form, that when submitted, has made the password a sha1.
Registration script:
if($_POST['pass1']==$_POST['pass2']){
$password = sha1(mysqli_real_escape_string($connection, $_POST['pass1']));
}
When the user log in, I have this script using sha1.
Login script:
$password = sha1(mysqli_real_escape_string($connection, $_POST['password']));
$sql=("SELECT id, email, username FROM users WHERE email='$email' AND pass='$password' LIMIT 1");
// AND THEN THE USER CAN LOG IN, CAUSE THE ENTERED PASS IN THE LOGIN FORM CHANGES THE
// PASS TO SHA1, LIKE WHEN THE USER REGISTERED.
Then I have made a forgot password script, that creates a random password like this.
Forgot password script:
$password = substr(md5(uniqid(rand(),true)), 10,15);
// Creates a unique temp password
$password = sha1($password);
// Then I make it a sha1
$query = "UPDATE users SET pass= '$password' WHERE id=$userid LIMIT 1";
This is my question/problem:
When the user has forgotten his password, I want to email him a new one.
So I reset the password completely, and email the user the new reset password.
Ass you can see in my script above: The password the user gets emailed, and that he has to use for login has been sha1 encrypted.
When he wants to login, the reset password, is once again being sent through a sha1 in the log in forms script, since this is the encryption, both the registration and login form uses, and that the login form needs to use to recognize the registered password, right?
But after running the new reset password through the login script, the script makes a sha1 encryption of the new reset password once again, and it doesnt recognize the reset password in the DB.....
I hope this makes sence.
The core issue is that after a user resets his password he cant login using the login form because it encryptes the reset password again...
How can I make a user reset his password, and use it in the login form that sha1 the password?
I hope this made sence!