The link provided did not work so I could not check the source code.
A better pattern match is
$pattern = "/^(+d{1,2}s)?(?d{3})?[s.-]d{3}[s.-]d{4}$/";
The if statement has two errors.
1) a elseif is needed
2) a condition/check is needed for the elseif
There are two else in a row; this is not allowed.
it looks like the proper code should be just a single else like this...
//Check for a valid phone number if (!empty($_REQUEST['phone'])) { // something was sent $phone = $_REQUEST['phone']; $pattern = "/^[0-9_]{7,20}/"; if (preg_match($pattern,$phone)){ $phone = $_REQUEST['phone']; } else { // illegal chars $errors[] = 'Your Phone number can only be numbers.'; } // end of preg_match } else { // no entry - blank $errors[] = 'You forgot to enter your Phone number.'; } // end of !emptyThis is how the code would be if more than one condition needed to be checked.// proper form of "if...elseif...else"if ( condition ) {// Type your code here} elseif ( condition ) { // other code} else { // other code} //Check for a valid phone number if (!empty($_REQUEST['phone'])) { $phone = $_REQUEST['phone']; $pattern = "/^[0-9_]{7,20}/"; if (preg_match($pattern,$phone)){ $phone = $_REQUEST['phone']; } else { $errors[] = 'Your Phone number can only be numbers.'; } else { $errors[] = 'You forgot to enter your Phone number.'; }