Click here to Skip to main content
15,921,774 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How can I make a forgot password function to my social media website?

What I have tried:

I have tried to find Out how to make a forgot password function but I haven't find anything. And I Don't know how to set it In my code if I find it out.
Posted
Updated 2-Jul-18 5:46am

Hopefully, you aren't storing the passwords either in plain text (very, very bad) or encrypted (still verry, very bad) but hashed - in which case once the user forgets the password, nobody knows what it is, or how to "recover" it.
Instead, when they press "forgotten my password" you email a link to the registered email address which contains a GUID or similar to identify which link was pressed. You then look that GUID up in a "forgotten password" table which contains and expiry date and time, plus a link to the original account. If it's all ok, you reset the password to a random value, tell them the new password, delete the row from the "forgotten password" table and take them to a "change your password" page to let them enter a new one.

Sounds complicated? it isn't, not really. But it has to be done this way to prevent me "stealing" your account!
 
Share this answer
 
Not knowing how to make a function could be a valid question and the first answer, by OriginalGriff gives you a lot of insight as to what should be considered, along with a flow.

I don't think that solves your problems as you added "
Quote:
And I Don't know how to set it In my code if I find it out.
leads me suspect you don't have any idea about how to use php at all. I suggest strongly that you got to this site and learn: PHP 5 Tutorial[^]

It's as though you asked 'what do I need to make soup', followed by a question like 'how do I cook'?
 
Share this answer
 
if passwords are saved in mysql database, then at every login there will be a button for forget password or reset password. on backend the function for this button will have a account verification against database and if the account exists, the text in new password textbox will replace the old password in database
 
Share this answer
 
Comments
Richard MacCutchan 2-Jul-18 11:51am    
And how will that verify that the person setting the new password is the real user?
muhammad sufiyan 2-Jul-18 11:56am    
when a user will create a new account, he will add a unique username/ID which only he will know. by the time of resetting password, this unique username/ID will be asked for authentication, which will verify the user's authentication
CHill60 3-Jul-18 7:21am    
usernames and IDs can be discovered or broken. You should also never store passwords on the database. This is a very bad solution, even when clarified

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900