I have a function for e-mail validation:
function checkemail($email)
{
$email = trim(strtolower($email));
$regexpattern = '^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$^';
return preg_match($regexpattern, $email);
}
when validating form input, just do:
if(!checkemail($_POST['email']))
// error ...
you can use the body of that function for URLs as well, just google an URL validating regular expression and replace my $regexpattern.