NYCPHP Meetup

NYPHP.org

[nycphp-talk] validating email address

Ben Sgro ben at projectskyline.com
Fri Dec 14 11:05:53 EST 2007


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

selyah wrote:
> Hello all:
> I have created a database which is working fine and i am now 
> validating the inputted data.   I am stuck on validating the email 
> address.  I am using the  validating statement below, and it is not 
> working.  when i enter the email incorrectly, it is still entered into 
> the database, and the errror msg is not printed.  can anyone see the 
> error of my ways.  thanks
> |if(||eregi||(||"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"||, $_POST['email']||||)) {|
> |  echo ||"Valid email address."||;|
> |  }|
> |else {|
> |  echo ||"Invalid email address."||;|
> |}|
> *//*
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php



More information about the talk mailing list