Jan 14, 2001 #1 Sina Technical User Jan 2, 2001 309 CA Does any one have a piece of code that would properly validate email addresses? Thanks for the help in advance.
Does any one have a piece of code that would properly validate email addresses? Thanks for the help in advance.
Jan 14, 2001 1 #2 vcherubini Programmer May 29, 2000 527 US Here is a little snippet of code that you can use: [tt] <?php function is_email_valid($email) { if(eregi("^[a-zA-Z0-9._-]+@([a-zA-Z0-9._-]+\.)+([a-zA-Z]){2,3}$", $email)) return TRUE; else return FALSE; } ?> [/tt] And you use the function such as so: [tt] $email = "me@zend.com"; if (is_email_valid($email)) print "E-Mail OK"; else print "E-Mail not valid"; [/tt] Hope this helps. -Vic vic cherubini malice365@hotmail.com http://www.epicsoftware.com==== Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director ==== Upvote 0 Downvote
Here is a little snippet of code that you can use: [tt] <?php function is_email_valid($email) { if(eregi("^[a-zA-Z0-9._-]+@([a-zA-Z0-9._-]+\.)+([a-zA-Z]){2,3}$", $email)) return TRUE; else return FALSE; } ?> [/tt] And you use the function such as so: [tt] $email = "me@zend.com"; if (is_email_valid($email)) print "E-Mail OK"; else print "E-Mail not valid"; [/tt] Hope this helps. -Vic vic cherubini malice365@hotmail.com http://www.epicsoftware.com==== Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director ====
Jan 14, 2001 1 #3 bluetac Programmer Dec 29, 2000 27 GB heres a regular expression that will do the trick function emailvalidator($emailaddress) { $result = ereg("^[^@ ]+@ ]+\.[^@ \.]+$", $emailaddress, $trash); if ($result) : ##email is good else : ##email is bad endif; return $something; } Andres Jugnarain Wireless Editor http://www.thetuckshop.com Upvote 0 Downvote
heres a regular expression that will do the trick function emailvalidator($emailaddress) { $result = ereg("^[^@ ]+@ ]+\.[^@ \.]+$", $emailaddress, $trash); if ($result) : ##email is good else : ##email is bad endif; return $something; } Andres Jugnarain Wireless Editor http://www.thetuckshop.com
Jan 15, 2001 Thread starter #4 Sina Technical User Jan 2, 2001 309 CA Thank you both for the code. Thanks much for taking the time. Regards, Sina Upvote 0 Downvote