if (strlen($centername) == 0) {
     $errors[] = "Please specify a Center Name";
 }
 if (strlen($countryid) == 0) {
     $errors[] = "Ensure you choose a country please";
 }
 if (strlen($address) == 0) {
     $errors[] = "Please provide the Center's Address";
 }
 if (strlen($city) == 0) {
     $errors[] = "The Center's City was not specified.";
 }
 if (strlen($state) == 0) {
     $errors[] = "Ensure the state or county of the Center is added";
 }
 if (!validate_telephone_number($phoneno, $formats)) {
     $errors[] = "Number is not valid, please try removing special characters at the beginning";
 }
 // were there any errors?
 if (count($errors) > 0) {
     $errorString = '<p>There was an error processing the form.</p>';
     $errorString .= '<ul>';
     foreach ($errors as $error) {
         $errorString .= "<li>{$error}</li>";
     }
     $errorString .= '</ul>';
     echo $errorString;
     // display the previous form
     //include 'centersuggest.php';
 } else {
     $query1 = "insert into ExamCenters \r\n(CenterName, CityName, Address1, State, Website, DateTimeEntered, EnteredById, PrimaryPhone, Email, CountryId)\r\n\r\nvalues ('" . $centername . "', '" . $city . "','" . $address . "','" . $state . "','" . $website . "', CURDATE(), '" . $USER->id . "','" . $phoneno . "','" . $email . "','" . $countryid . "')";
function validate_phone_number($number)
{
    $formats = array('###-###-####', '(###) ###-####', '###.###.####', '(###) ###.####', '(###)###-####', '(###)###.####', '##########');
    return validate_telephone_number($number, $formats);
}