views:

56

answers:

2

Hi,

How can I verify an email address with codeigniter? I just went through the manual, I couldn't find this.

With email verification, i mean the exact same verification you see when registering on a community forum.

Thanks in advance!

A: 

You will need validation library, you can find more information about the validation library on the following link: http://codeigniter.com/user_guide/libraries/validation.html

KoKo
Hi, not validation but verification. When someone registers, they'll be send an email with a link. That link has to be clicked in order to activate the account of that user. Exaclty like for example this forum: http://www.programmingforums.org/ you can't post here untill you register and verify/confirm you're the owner of that email address you gave at registration.
Yustme
+3  A: 

Use the Email Class to send the email. The email could contain a link with a "secret key", something random and hash-like, like 5dfg7898ssdf (I made that one up :) ). The link could point to: example.com/verify/user/5dfg7898ssdf Then in a codeigniter controller called "verify", you put this function (just some quick code):

function user($key = NULL)
{
 if($key)
 {
  // Find key in database
  // If it exists, then mark
  // the corresponding user as "activated"
 }
}
Matthew
Its what i do all the time. Verifies an email exists by forcing a user to view their email!
dotty
Yep, this is the way I would do it as well. Create a unique verification key for that user, store it in the database as a field in the 'users' table, and create a public method in your "user" controller called "verify($key)" or something like that. Then in your email, link the user to:http://example.com/user/verify/520592u02492089
treeface
Writing a unique key to the db is the best way to do it, but if for some reason you don't want to use a db field then it would be better to use a salted md5 hash based on the users' email or username rather than having a static secret key like Matthew seemed to suggest.
Calle
Thanks! That should do the trick. I'll try it out later.
Yustme
@Calle I didn't mention having a "static" secret key. It would have to be dynamic (it has to verify a specific email, not just any email).
Matthew