I am using php 5.3 with the php 3 and php 4 book. I've hade to substitute preg_match for eregi. It's working for the first two but not the third test, below. Any suggestions for what's wrong?
if (!preg_match("#^[[:alpha:].'-]{4,}$#i", stripslashes(trim($_POST['name'])))) {
$problem = TRUE;
$message .='<p>Please enter a valid name.</p>';
}
if (!preg_match("#^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$#i",
stripslashes(trim($_POST['email'])))) {
$problem = TRUE;
$message .='<p>Please enter a valid email address.</p>';
}
if (!preg_match("#^((http|https|ftp)://)?
([[:alnum:]-])+(\.)
([[:alnum:]]){2,4}
([[:alnum:]/+=%&_.~?-]*)$
#i",
stripslashes(trim($_POST['url'])))) {
$problem = TRUE;
$message .='<p>Please enter a valid URL.</p>';
}
I've tried with several values which should be valid URL names.