I have a php function to validate an email address in my flash form, but there is one problem.
The function valid_email only works if your email address is something like:
But it comes up invalid email if your address is:
**test@test.co.uk **
[color=#006699]test@test-test.com[/color]
Does anyone know how to change the function so you can have email address like:
**test@test.co.uk **
[u][color=#006699]test@test-test.co.uk[/color][/u]
as well as [u][color=#006699]test@test.com[/color][/u].
Here is the function from the tutorial:
function valid_email($email)
{
// check if email is valid
if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"
."@([a-z0-9]+([\.-][a-z0-9]+))*$",$email, $regs))
{
return false;
} else if( gethostbyname($regs[2]) == $regs[2] )
{
// if host is invalid
return false;
} else {
return true;
}
}