Sahal
Sahal

Reputation: 4136

What is the best way to do 'Reset Password' functionality in php?

What is the best way to do 'Reset Password' functionality in php ?

Two step process.

Can anybody right the script flow for this ?

Upvotes: 0

Views: 735

Answers (1)

Noki Flores
Noki Flores

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:

http://www.yourdomain.com/resetpassword.php?_u=82cc5b9e02d711035aafef9e18c7eb26973e8962&tokenid=82cc5b9e02d711035aafef9e18c7eb26973e8962

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

Related Questions