note 16368 added to function.ereg

From: Date: Fri, 26 Oct 2001 14:31:11 +0000
Subject: note 16368 added to function.ereg
Groups: php.notes 
Request: Send a blank email to php-notes+get-19472@lists.php.net to get a copy of this message
All the e-mail validation functions will return info@info.info as an invalid e-mail address. All of the functions check the number of characters after the last dot, and it can be 2 or 3 and here it's 4 :) Here's the tweaked function: function is_validEmail($email) { if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$", $email, $check)) { if ( getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) ) { return TRUE; } // THIS WILL CATCH DNSs THAT ARE NOT MX. if(checkdnsrr(substr(strstr($check[0], '@'), 1),"ANY")){ return TRUE; } } return FALSE; } or the Windows version (where DNS functions don't work): function is_validEmail($email) { if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$", $email, $check)) return TRUE; return FALSE; } Cheers everybody! Saveli. -- http://www.php.net/manual/en/function.ereg.php http://master.php.net/manage/user-notes.php?action=edit+16368 http://master.php.net/manage/user-notes.php?action=delete+16368 http://master.php.net/manage/user-notes.php?action=reject+16368

« previous php.notes (#19472) next »