Hello all. I’m quite new at this, so I apologize if this is a really stupid question.
I’m setting up a basic log-in system with a password retrieve option. All passwords are hashed with MD5, and all posts are sanitized to prevent MySQL injection.
If a user forgets his password and answers the security question correctly, his password gets reset to a random 8-character string. A non-hashed copy of that string gets sent to the corresponding email address pulled from the MySQL database. The email is sent using the basic mail function:
mail ($email, ‘Your Login Information.’, $message);
Now, did I just throw away all the security I’ve been trying to preserve? Is there a better way to do this?
Any input is appreciated. Once again, I apologize if the answer is stupidly obvious.