Exemple #1
0
function createQuery()
{
    // initializes an array with the empty String and false
    $conditions = array('SELECT * FROM wp_meetings WHERE ', false);
    // checks url query string and updates conditions array with helper functions
    $conditions = checkName($conditions);
    $conditions = checkCity($conditions);
    $conditions = checkZipcode($conditions);
    $conditions = checkBooleans($conditions);
    // if any of the conditions were met, adds AND to String so that in cmafunction the day can be added
    if ($conditions[1]) {
        $conditions[0] = $conditions[0] . " AND ";
    }
    // uncomment next line see String that's being returned at top of page
    //echo "<p>$conditions[0]</p>";
    return $conditions[0];
}
}
// Validate the firstname
checkMandatory("firstname", "first name", "custErrors", "custFormVars");
// Validate the Surname
checkMandatory("surname", "surname", "custErrors", "custFormVars");
// Validate the Address
checkMandatory("address", "address", "custErrors", "custFormVars");
// Validate the Initial
if (!empty($_SESSION["custFormVars"]["initial"]) && !eregi("^[[:alpha:]]{1}\$", $_SESSION["custFormVars"]["initial"])) {
    $_SESSION["custErrors"]["initial"] = "The initial field must be empty or one " . "alphabetic character in length.";
}
// Validate the City
checkMandatory("city", "city", "custErrors", "custFormVars");
// Validate Zipcode
if (checkMandatory("zipcode", "Zip code", "custErrors", "custFormVars")) {
    checkZipcode("zipcode", "Zip code", "custErrors", "custFormVars");
}
// Phone is optional, but if it is entered it must have correct format
if (!empty($_SESSION["custFormVars"]["phone"])) {
    checkPhone("phone", "telephone", "custErrors", "custFormVars");
}
// Validate Date of Birth
if (checkMandatory("birth_date", "date of birth", "custErrors", "custFormVars")) {
    checkDateAndAdult("birth_date", "date of birth", "custErrors", "custFormVars");
}
// Only validate email if this is an INSERT
if (!isset($_SESSION["loginUsername"])) {
    if (checkMandatory("loginUsername", "email/username", "custErrors", "custFormVars") && emailCheck("loginUsername", "email/username", "custErrors", "custFormVars")) {
        // Check if the email address is already in use in
        //  the winestore
        $query = "SELECT * FROM users WHERE user_name = \n                '{$_SESSION["custFormVars"]["loginUsername"]}'";