[PHP] mail and mysql confirmation of that [double-opt in]

2009-06-29 Thread Grega Leskovsek
how is the best way to check if email address is valid: is this preg_match() OK?
preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/',
$email);

How can I make double opt-in mail system? My idea:
1.) I remember the email entered and user data and the sha1($email);
in mysql db
2.) I send email with activation link of the sha1($email);
3.) I am not clear how to proceed when the link is activated. How to
update the db and submit the necessary form to the marketing.

Thanks in advance,


-- 
When the sun rises I receive and when it sets I forgive ->
http://users.skavt.net/~gleskovs/
All the Love, Grega Leskov'sek

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mail and mysql confirmation of that [double-opt in]

2009-06-29 Thread tedd

At 4:55 PM +0200 6/29/09, Grega Leskovsek wrote:
how is the best way to check if email address is valid: is this 
preg_match() OK?

preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/',
$email);

How can I make double opt-in mail system? My idea:
1.) I remember the email entered and user data and the sha1($email);
in mysql db
2.) I send email with activation link of the sha1($email);
3.) I am not clear how to proceed when the link is activated. How to
update the db and submit the necessary form to the marketing.

Thanks in advance,


Double opt-in.

1. Have the user enter their email address via a form that let's them 
know they are subscribing to a service. You might want to check for a 
valid email address (many versions) and/or a CAPTCHA. additionally, 
you need to check if they have already registered OR in the process 
of registering.


2. After they submit their email address, then have your script 
create a unique token and record it coupled with the email address in 
your database.


3. Then send a confirmation email to that email address with the 
token appended as a link in the email -- with instructions for the 
receiver to either ignore the email (with apologies) or click the 
link and be taken back to your site where your script takes the 
confirmation token and checks your database for a token/email match. 
If there is one, then that completes the process and you have a 
confirmed double opt-in email address to use. If not, have them try 
again.


Here's the script I wrote to do that:

http://www.webbytedd.com/b/sub-email/index.php

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mail and mysql confirmation of that [double-opt in]

2009-06-29 Thread Shawn McKenzie
Grega Leskovsek wrote:
> how is the best way to check if email address is valid: is this preg_match() 
> OK?
> preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/',
> $email);

filter_var($email, FILTER_VALIDATE_EMAIL)

> 
> How can I make double opt-in mail system? My idea:
> 1.) I remember the email entered and user data and the sha1($email);
> in mysql db
> 2.) I send email with activation link of the sha1($email);
> 3.) I am not clear how to proceed when the link is activated. How to
> update the db and submit the necessary form to the marketing.

When the user clicks the activation link, mark the address active in the
subscribers table, or move the entry from a pending table to a
subscribers table.  Then execute the email/whatever to marketing just as
you would without using double opt-in.

> 
> Thanks in advance,
> 
> 

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php