Email validation

From: Date: Wed, 21 Mar 2001 04:33:24 +0000
Subject: Email validation
Groups: php.general 
Request: Send a blank email to php-general+get-44872@lists.php.net to get a copy of this message
Hello Again, Can anyone tell me what the best form of Email validation there is? It needs to be quick & as open to - and . as possible. I've seen the following: <? if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$", $Email)) { $error = 1; $error_html .= "This email address is invalid: " . $Email; echo $error_html; } ?> But this one looks quite impressive too: <? function checkaddress($mail) { if ( !ereg( "^([0-9,a-z,A-Z]+) ([.,_] ([0-9,a-z,A-Z]+))*[@] ([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z] +))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $mail ) ) { return false; } else { return true; } } ?> Not sure which is the best. Mike -- Mike Gifford, OpenConcept Consulting, http://openconcept.ca Offering everything your organization needs for an effective web site. Latest Featured Site: http://www.lornenystrom.org/ No problem can be solved with the same thinking that created it - A.Einstein

« previous php.general (#44872) next »