Jump to content

Recommended Posts

[!--quoteo(post=389268:date=Jun 29 2006, 03:42 PM:name=Buyocat)--][div class=\'quotetop\']QUOTE(Buyocat @ Jun 29 2006, 03:42 PM) [snapback]389268[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I suggest looking into the PEAR package, Validator - or something like that. I use it to verify emails and it works like a charm. Even if you don't want the extra code, it is worth checking out to see what regular expression they use.
[/quote]
I took a 2nd glance and realised i forgotte to put the .com // .co.uk etc. part so it should have looked like:

[code]
$mail = $_POST['mail'];
if( !preg_match("/[A-Za-z0-9\._%-]+\@[A-Za-z0-9\._%-]+.[A-Za-z0-9\]/", $mail)){
die('error: no email');
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/13208-preg_match/#findComment-50841
Share on other sites

[!--quoteo(post=389274:date=Jun 29 2006, 10:50 AM:name=Ashh)--][div class=\'quotetop\']QUOTE(Ashh @ Jun 29 2006, 10:50 AM) [snapback]389274[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I took a 2nd glance and realised i forgotte to put the .com // .co.uk etc. part so it should have looked like:

[code]
$mail = $_POST['mail'];
if( !preg_match("/[A-Za-z0-9\._%-]+\@[A-Za-z0-9\._%-]+.[A-Za-z0-9\]/", $mail)){
die('error: no email');
}
[/code]
[/quote]

about the best email validation i've found is this:
[code]
preg_match('|^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$|i', $email);
[/code]

the only things you're really missing is the '^' at the beginning and the '$' at the end to make sure that nothing funky has been going on in front or behind it.
Link to comment
https://forums.phpfreaks.com/topic/13208-preg_match/#findComment-50861
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.