verify a user via e-mail in PHP

前端 未结 3 2030
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-15 00:21

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

3条回答
  •  时光说笑
    2021-01-15 00:32

    This is a very broad question, so we can only give a broad answer, but the general technique to do so is

    1. insert the user's email address into your database but mark it as unverified
    2. create a unique registration key and insert it into a different table just for these keys
    3. send an email to the user's email address with a link to your site that passes this registration key as an argument (eg http://site.com/confirm.php?key=1234)
    4. when that url is visited, mark the email as verified and remove the temporarily created registration key

提交回复
热议问题