Exemple #1
0
    }
    if (!$_POST['city'] || !preg_match(" /[^\$%\\^*£=~@0123456789]/ ", $_POST['city'])) {
        $errCity = 'Please enter your city';
    }
    if (!$_POST['phone'] || !preg_match("/^[0-9]+\$/", $_POST['phone'])) {
        $errPhone = 'Please enter your phone number';
    }
    if (!$_POST['participation']) {
        $errParticipation = 'Participation statement is required';
    }
    // If there are no errors, send the email
    if (!$errName && !$errMail && !$errStreet && !$errStreetnumber && !$errZip && !$errCity && !$errParticipation && !$errPhone) {
        $db = new SQLite3('db.sqlite3');
        $query = sprintf("INSERT INTO guest (lastname, firstname, mail, street, streetnumber, zip, city, phone, participation, comment) VALUES\r\n                                      ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $lastname, $firstname, $mail, $street, $streetnumber, $zip, $city, $phone, $participation, $comment);
        #echo '<p>'.$query.'</p>';
        $count = $db->exec($query) or die(print_r($db->errorInfo(), true));
        $db->close();
        if ($count !== 0) {
            $result = '<div class="alert alert-success">Guest successfully added! Reloading...</div>';
            $page = $_SERVER['PHP_SELF'];
            $sec = "2";
            header("Refresh: {$sec}; url={$page}");
        } else {
            $result = '<div class="alert alert-danger">Sorry there was an error executing your query. Please try again later.</div>';
        }
    }
}
?>

<!DOCTYPE html>
<html lang="en">