コード例 #1
0
        foreach($_SESSION as $value) {
   echo  'Current session variable is: ' . $value . '<br />';
        }
*/
// Validation stuff
function isLetters($str)
{
    $pattern = '/[A-Za-z]+$/';
    return preg_match($pattern, $str);
}
echo "<p><strong>Errors: </strong></p>";
// Check the bookingName
if (isEmpty($bookingName)) {
    echo "<p>Name cannot be empty</p>";
} else {
    if (!isLetters($bookingName)) {
        echo "<p>Name must be letters only.</p>";
    } else {
        $passCounter++;
    }
}
if (isEmpty($roomSelection)) {
    echo "<p>Room cannot be empty</p>";
} else {
    $passCounter++;
}
// Check details of check in check out
$errorArray = checkDetails($checkinDate, $checkoutDate);
if ($errorArray != null) {
    foreach ($errorArray as $error) {
        echo "<p>{$error}</p>";
コード例 #2
0
}
// Check the street address
if (isEmpty($address)) {
    echo "<p>Address cannot be empty</p>";
} else {
    if (!isLetters($address)) {
        echo "<p>Address must be letters only</p>";
    } else {
        $passCounter++;
    }
}
// Check the city
if (isEmpty($city)) {
    echo "<p>City cannot be empty</p>";
} else {
    if (!isLetters($city)) {
        echo "<p>City must be letters only</p>";
    } else {
        $passCounter++;
    }
}
// Check the postcode
if (isEmpty($postcode)) {
    echo "<p>Postcode cannot be empty</p>";
} else {
    if (!isDigits($postcode)) {
        echo "<p>Postcode must be numbers only</p>";
    } else {
        $passCounter++;
    }
}