Most of the websites will require the users to register them for getting username/password which can be used for logging into their website.
It is very common that the users forget their password. So, the websites should allow the users to receive their password into their email using forgot password link available in the login page.
Find below the sample php code which can be used for implementing the forgot password feature.
The step involved are,
1. First provide a form with input text box with name "email" for allowing the user to enter his email id.
2. On submitting this form, the "email" will be posted to the php page mail-password.php.
3. From user table, query the password corresponding to the entered email id. (If you have stored the password in encrypted form then reset it with default/random password and send this default/random password to the user)
4. Validate the email id.
5. Prepare the email message and send it using php mail() function.
You can bookmark this blog for further reading, or you can subscribe to our blog feed.