Email address validation
This is a useful little routine to validate email addresses . To test this change the $email1 variable and see what results you get . You can remove the @ , forget to put the full stop before the com , make the com part too small e.g only 1 character.
Code
<?php
Function ValidEmail($email)
{
if (eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$" , $email))
return true;
else
return false;
}
?>
<?php
$mail1 = "iain@excitecom";
If (ValidEmail($mail1))
echo "valid email address";
Else
echo "invalid email address";
?>
Example:
invalid email address