#1
  1. Essentials and Non-Essentials.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    USA
    Posts
    491
    Rep Power
    25

    best way to send email validation


    What is the best way to send out a unique validation e-mail to each user within a database. The validation e-mail is to ensure that the person really has that e-mail address. Once they get the e-mail, they are required to click on a special link with a unique validation code.

    I'm a little unsure of the best and most efficient/secure way of implementing a system like this. This is how I see it at the moment:

    The user enters their e-mail address in system and then my script will enter their e-mail address in database but will mark it as temporary (in another row). My script will then create a random number between 9 and 12 characters long. This will be placed into another row in the database. Then my script will send an e-mail to the e-mail address given with a link which contains this validation code.

    Once the user clicks on the link in their e-mail, it will do a select query for their e-mail address based on their validation code, ie.

    PHP Code:

    $result 
    mysql_query("SELECT emailaddress, status FROM contacts WHERE validationID=20349822028"$dbconn); 
    If a result is found, then status will be changed from temp to confirmed and the e-mail address is now confirmed.

    This was the first idea I came up with, I haven't looked at others yet, but I just wanted to know the best and most secure way of doing it. Is the way above okay? How can it be improved? Any ideas appreciated.

    Thanks,

    Nathan
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    USA
    Posts
    477
    Rep Power
    59
    thats how I did it, I can't think of a way any more efficient.
  4. #3
  5. Essentials and Non-Essentials.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    USA
    Posts
    491
    Rep Power
    25
    hi chibiguy,

    Sounds good to me, I think I will just go with this method then.
    Just good to know that others are implementing similar methods.

    Cheers,

    Nathan

IMN logo majestic logo threadwatch logo seochat tools logo