Is this good code for email validation:
Code: Select all
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) {
$error_msg = '<center><b>Invalid email address</b></center>';
}Thanks
Moderator: General Moderators
Code: Select all
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) {
$error_msg = '<center><b>Invalid email address</b></center>';
}According to RFC 2822, the local-part of the e-mail may use any of these ASCII characters:
Uppercase and lowercase letters
The digits 0 through 9
The characters "!", "#", "$", "%", "&", "'", "*", "+", "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~"
The character "." provided that it is not the first or last character in the local-part.
You are confusing valid (according to the RFC) email addresses with accurate and working - there is a very significant difference.seodevhead wrote:I am currently testing it and am seeing that it accepts a lot of invalid email addresses, eventhough it is not supposed to.
If you are at my house, and you ping my router (named "Evil"), you get:seodevhead wrote:I mean seriously, how can 'cal@iamcalx' be considered a valid email address? I don't understand this function at all. Perhaps I am missing something. Any help would be greatly appreciated! Thanks.