Example #1
0
/**
 * Checks whether the user exists.
 * @param email the email address of the user.
 * @return boolean whether the user exists.
 */
function user_exists($email)
{
    $s_email = functions\sanitize_string($email);
    $query = "SELECT * FROM " . USER_TABLE . " WHERE email_address='{$s_email}'";
    if (mysql_num_rows(mysql_query($query))) {
        return true;
    } else {
        return false;
    }
}
Example #2
0
/**
 * Updates the spots taken in the trip.
 * @param trip_id the id of the trip to be updated
 * @return spots_taken the new number of spots taken in trip. -1 if failed.
 */
function update_spots_taken($trip_id)
{
    $trip_table = TRIP_TABLE;
    $trip_request_table = TRIP_REQUEST_TABLE;
    $trip_id = functions\sanitize_string($trip_id);
    $spots_query = "SELECT * FROM {$trip_request_table}\n                    WHERE trip_id = '{$trip_id}' \n                    AND status = 1";
    $spots_taken = mysql_num_rows(mysql_query($spots_query));
    $update_query = "UPDATE {$trip_table} \n                     SET spots_taken='{$spots_taken}'\n                     WHERE id = '{$trip_id}'";
    error_log($spots_taken);
    if (mysql_query($update_query)) {
        return $spots_taken;
    } else {
        return -1;
    }
}