You need to actually call the function...
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
// check an email address is possibly valid
if (isset ($_POST['submit']{
validateEmail($_POST['address']);
}
else
{
print '<form action="handle_reg.php" method="post">
<p>EMAIL: <input type="text" name="address" size="20" /></p>
<input type="submit" name="submit" value="validate" />
</form>';
}
function validateEmail($address)
{
if(empty($address))
{
echo 'No Address Given';
return;
}
// This regex pattern lifted from user-notes at php.net
$domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)';
$atom = '[-a-z0-9!#$%&\'*+/=?^_`{|}~]';
$pattern = '^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}' . '$';
if(!eregi($pattern, $address))
{
echo 'Address Validation Failed!';
}
else
{
echo 'Address Is Valid!';
}
return;
}
Hope that helps.