Confirm registration email address with PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Confirm registration email address with PHP?

Post by JAB Creations »

So I have registration working just fine and dandy locally and would like to have folks who register confirm their email addresses actually exist. I would imagine the essentials would be to create some sort of URL with a unique string that is stored in the DB, sent in an email automated by PHP, and compared when clicked to validate the email address. I'm not sure where to start however. Any good examples or good threads to share?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

It's not complicated at all

1) User registers at your site, insert record into the database
2) Update user record with a unique id of some sort, md5($username. rand(0, 100000) . microtime()) for example
3) Send the email with a link containing the unique id, i.e.http://domain.com/confirm.php?id=YOUR_UNIQUE_HASH
4) Check for the existence of the hash in the database
5) If found, update user record to confirmed
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Just know that users can use temporary email addresses if they don't want to use their "real" one, so there's really no way of actually knowing if it's theirs or not. You just hope for the best.
Post Reply