Reputation: 4136
What is the best way to do 'Reset Password' functionality in php ?
Two step process.
User will enter the email Id, mail will send him to user with the link.
When user click the link, he can see tow fields to reset his password.
Can anybody right the script flow for this ?
Upvotes: 0
Views: 735
Reputation: 257
i hope this will help you. first you have to create a table name "token" with a column of seqid,tokenid,status.. sequence id will represent the sequence number tokenid in a hash form and the status it explain itself.
Now you have to compute a url that is one time used only after the user click the reset password the system will generate a tokenid (its up to you how to generate a hash value) and then compose a url that will be submitted to the user via email
domain name/function Or Page ? username(in hash form) & tokenid
example:
after the user click the url it will go to function and check who is the user or if it is existing and the tokenid if it is already expired
ex. "select user from users where sha1(username) = $userInHashForm "
"Select * from token where tokenid = $tokenid AND status = 'active'"
and then reset his/her password when its done you need to change the status of the token to "inactive" so it cannot be used again
thanks please rate! goodluck
Upvotes: 6