Jump to content

[SOLVED] registration, sending a validation mail


Yeodan

Recommended Posts

I'm just wondering how I should handle this.

 

I want people who want to register to put in their email adress, then I want to validate the email, if it's a valid mail I want to send a mail to that email adres with a link the use should click to activate their account.

 

 

A few things I'm wondering:

 

Should I validate the mail, and how do I do this, I've seen like 20 sites, they all do it a diffrent way, and none of them works 100% for every possible email.

 

Are there any requirements to make the validation mail secure? I was just thinking of using a number between 1-10000 + the account number, storing both in a seperate table with all the user info and when the link is clicked moving the info to the real table where accounts are stored. Is that any good?

No, moving the record from one table to another is not the standard practice to address your requirements.

 

The easiest way and most common is to keep the records in the same table but have a boolean field (0/1) to indicate whether the record has been activated by email.

 

You can generate a random string then md5() it to get an activation token which you can use in the email.

 

 

As for validating an email address, this has always worked for me:

 

if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email))
{
//email is NOT valid
}

i do something similar in my apps - only one that i've ported to php, though, but still the same idea. the first registration page asks the user for his/her email address. when they submit that form, a unique authorization code is generated, then stored in the database along with the email address and an expiration date as well as a is_used flag. then a message is emailed to the email address that allows them to continue the registration process which doesn't include the ability to update their email address. when the url is clicked, i validate the authorization code exists, hasn't been used and hasn't expired. if the validation succeeds, then i update the is_used flag and the registration process begins.

 

jason

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.