Created
January 1, 2012 11:38
-
-
Save robhimself82/1547105 to your computer and use it in GitHub Desktop.
PHP Email Validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| if (isset($_POST['action']) && !empty($_POST['action'])) { | |
| $action = $_POST['action']; | |
| switch($action) { | |
| case 'validate_domain': | |
| // If we're not passing in an email address, automatically return false. | |
| if (!isset($_POST['email']) || empty($_POST['email'])) return false; | |
| return domain_exists($_POST['email']); | |
| break; | |
| } | |
| } | |
| function domain_exists($email, $recordType = 'MX') { | |
| list($user, $domain) = split('@', $email); | |
| echo checkdnsrr($domain, $recordType) ? "true" : "false"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment