I'm actually creating a web application using PHP and seek help verifying a user.
As with certain websites, when you register, an e-mail is sent to you with a confirmation link. How do I implement that in PHP?
All I know is that I have to use the PHP mail()
function to send the e-mail.
Please help. Necessary. Thanks. :)
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
This is a very broad question, so we can only give a broad answer, but the general technique to do so is
just like with CSRF protection you generate an unique token.
You store that value in your session for that email and when the user clicks link in email(you pass token via the query-string) you compare the two values.
To make it more secure you could just as with CSRF add a time-limit.
Patricks answer is correct altough i want to point out that there are other possibilities!
You don't necessarily have to create and store a unique token in your database. This is data overhead that is only needed once.
You could also take advantage of one-way hashing.
For example send the user the code
md5('my-secret-application-token'.$user_email_adress)
.You can validate that just the same way but dont need to store a secret code.