简体   繁体   中英

Sending verification mail before registering user - PHP

I am currently working on the PHP project in which I have to send the verification mail to the user who register in the site. (Email id is the username). I am having the following doubt.

  • Whether I have to send them the verification email before storing the user in database or after storing the user in database.
  • If I send the verification mail to the user after storing user in database what I have to do if the email is not sent from my server. Because user cannot able to re-register with the same email id.

Please help me in this problem. Thanks in advance

  • you have to send mail after registration save details in db with key(that will send with link) and status like 0 in database . if they click on that link then delete activation key from database and also change status into 1 and on login you also need to check user have status 1 if not then you can show alert like Mail Confirmation Pending .

  • after send mail you can check mail sent or not .check this question

I suggest you store the user in database and then send the verification email. In the database keep a field to mark whether user verified the email or not.

Give user an option to resend email verification incase they didn't receive.

As far as from my experience

  1. Enter details in DB and then send the verification mail, else your in a situation that you cant verify the user back again.

  2. In-case email sending fails from your side, provide a option for the user to request for resending of the verification mail.

  3. Maintain a status in the DB whether a user is verified or not, and based on that you can resend the verification mail.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM