I am trying to hack a bit of code for a form. Basically, I want the user to either fill in a telephone number OR an email address, but not necessarily both. If neither are filled, in the form colours the fields in red and issues a warning
Effectively this :
if ((if statement1) OR (statement2))
The following are the two statements that need to be or'd :
//Statement 1
if((empty($_POST['telephone'])) {
$errormessages[] = 'Please enter your telephone.';
$errorfields[] = 'telephone';
}
// Statement 2
if(empty($_POST['email'])) {
$errormessages[] = 'Please enter your email address.';
$errorfields[] = 'email';
} else {
if(!eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $_POST['email'])) {
$errormessages[] = 'Please enter a proper email address for yourself.';
$errorfields[] = 'email';
}
}
Just had a thought. Should it be :
if ((if not statement1) AND (if not statement2))
???
Hmm. Whole damn thing needs juggling methinks !
Just can't quite get my head round doing it. Any help would be greatly appreciated.