Search code examples
phpmysqlemail-validation

Verify emails using PHP


How can I verify when a visitor registers on my website, that the email he/she has used is valid. I would like to email them a link which they can click to prove their membership, how can this be done?


Solution

  • At a high level, what you want to do is roughly the following:

    • When a user registers, create a secret code that the user can't figure out himself
      • This can be something that is randomly assigned like a random string
      • This can also be something that you can calculate programmatically (but that the user can't) like an MD5 of the user's email address concatenated to a secret string; doing this could save you a database column since you wouldn't have to store it
    • Save the secret code and send it to the user in the form of a link in an email
    • Set up a listener at that link, and if the codes match, "activate the user"

    As for how to do this step-by-step, tutorials abound.