This code snipit checks to see if the input is a valid email or not, it will even check to see if the domain name is in use so ‘fake’ email domains will be rejected, this will help keep your database clean!
1 |
<pre><code>function isValidEmail($email) { //Perform a basic syntax-Check //If this check fails, there's no need to continue if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { return false; } //extract host list($user, $host) = explode("@", $email); //check, if host is accessible if (!checkdnsrr($host, "MX") && !checkdnsrr($host, "A")) { return false; } return true; }</code>
|
source: http://css-tricks.com/forums/discussion/17370/make-sure-email-field-is-valids/p1
Blog post by Alex Wells
Working as a Website developer I love nothing more then working waist deep in code, I have specific interests in PHP and WordPress development but mostly working with local businesses to provide them with a website that meets their needs. Contact me if you have a project in mind and would like to get an input from an experienced website developer.
