Call us Toll-Free:
1-800-218-1525
Email us

 Sponsors

Email validation 1

Code Wizard, 12-30-2006

This function checks email for validity: check for '@', '.' characters and bad characters that you can define yourself.

<?
################################################## ###########
# This function checks email for validity5:
# check for '@', '.' characters and bad characters that you
# can define yourself.
# Contact us at: webmaster@php.inc.ru
# Welcome to our Web site at http://php.inc.ru
################################################## ###########
function check_email($email)
{
$emailArray = preg_split('//', $email);
$atSign = false;
$dotSign = false;
$badCharacter = false;
$validEmail = true;


if (in_array ("@", $emailArray))
{
$atSign = true;
}
if (in_array (".", $emailArray))
{
$dotSign = true;
}

$badCharactersArray = array('#', '$', '%', '(', ')', '&', '!'); // Add your own bad
// characters here;

for ($i = 0; $i < sizeof($badCharactersArray); $i++)
{
if (in_array ($badCharactersArray[$i], $emailArray))
{
$badCharacter = true;
}
}

if ((!$atSign) or (!$dotSign) or ($badCharacter))
$validEmail = false;
}
?>
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions