/ Published in: PHP
Checks for fake DNS as well as utilizes regex functions to check the string for proper length & characters.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function validateEmail($email) { $isValid = true; { $isValid = false; } else { if ($localLen < 1 || $localLen > 64) { $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { $isValid = false; } else if ($local[0] == '.' || $local[$localLen - 1] == '.') { $isValid = false; } { $isValid = false; } { $isValid = false; } { $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\", "", $local))) { { $isValid = false; } } { $isValid = false; } } return $isValid; } ?>