$form_password = filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING);
$form_confirmpassword = filter_input(INPUT_POST, "confirmpassword", FILTER_SANITIZE_STRING);
+global $is_logged_in;
+if (!$is_logged_in) {
+ echo "Please login first. <br>";
+ $_SESSION['login_referer'] = $_SERVER['HTTP_REFERER'];
+ redirect("index.php?page=login", 2);
+}
+
$input_failure = false;
$password_failure = false;
if (!empty($form_name) && !empty($form_firstname) && !empty($form_numstreet) && !empty($form_street) &&
!empty($form_postalcode) && !empty($form_city) && !empty($form_email) &&
- !$input_failure) {
+ !$input_failure && $is_logged_in) {
global $connection;
$client_id = get_client_id($_SESSION['email']);
$sql_pquery = "update CLIENTS
echo "You've updated your personal informations, you will be redirected to your account in 3 seconds. <br>";
redirect("index.php?page=account", 3);
} elseif (!empty($form_oldpassword) && !empty($form_password) && !empty($form_confirmpassword) &&
- !$password_failure) {
+ !$password_failure && $is_logged_in) {
if (chk_password($_SESSION['email'], $form_oldpassword)) {
global $connection;
$client_id = get_client_id($_SESSION['email']);
<?php
$form_flight_id = filter_input(INPUT_POST, "flight_id", FILTER_SANITIZE_STRING);
$form_nb_place = filter_input(INPUT_POST, "nb_place", FILTER_VALIDATE_INT);
+$form_previous_class_name = filter_input(INPUT_POST, "previous_class_name", FILTER_SANITIZE_STRING);
$form_class_name = filter_input(INPUT_POST, "class_name", FILTER_SANITIZE_STRING);
+global $is_logged_in;
+if (!$is_logged_in) {
+ echo "Please login first. <br>";
+ $_SESSION['login_referer'] = $_SERVER['HTTP_REFERER'];
+ redirect("index.php?page=login", 2);
+}
+
$input_failure = false;
if (!$form_nb_place) {
$input_failure = true;
}
-if (!$input_failure && !empty($form_nb_place) && !empty($form_class_name)) {
+if (!$input_failure && $is_logged_in && !empty($form_nb_place) && !empty($form_class_name)) {
global $connection;
$client_id = get_client_id($_SESSION['email']);
$sql_pquery = "update RESERVATIONS
set NbPlaces = ?, Classe = ?
- where NumCl = ? and NumVol = ?";
+ where NumCl = ? and NumVol = ? and Classe = ?";
$connection->prepare_query($sql_pquery);
- $connection->prepared_query_bind_param("isis", array($form_nb_place, $form_class_name, $client_id, $form_flight_id));
+ $connection->prepared_query_bind_param("isiss", array($form_nb_place, $form_class_name, $client_id, $form_flight_id, $form_previous_class_name));
$connection->run_prepared_query();
$connection->close_prepared_query();
echo "Modifications enregistrées. <br>";
$form_class_name = filter_input(INPUT_POST, "class_name", FILTER_SANITIZE_STRING);
$form_cancel = filter_input(INPUT_POST, "cancel", FILTER_SANITIZE_STRING);
-if (isset($form_cancel) && isset($form_flight_id) && isset($form_class_name)) {
+global $is_logged_in;
+if (!$is_logged_in) {
+ echo "Please login first. <br>";
+ $_SESSION['login_referer'] = $_SERVER['HTTP_REFERER'];
+ redirect("index.php?page=login", 2);
+}
+
+if (isset($form_cancel) && isset($form_flight_id) && isset($form_class_name) &&
+ $is_logged_in) {
$client_id = get_client_id($_SESSION['email']);
global $connection;
$sql_pquery = "delete from RESERVATIONS
<select size="1" name="departure_city" required>
<optgroup label="Sélectionner une ville">
<?php
- $sql_pquery = "select distinct VilleD from VOLS";
+ $sql_pquery = "select distinct VilleD from VOLS order by VilleD";
global $connection;
$connection->prepare_query($sql_pquery);
$connection->run_prepared_query();
<select size="1" name="arrival_city" required>
<optgroup label="Sélectionner une ville">
<?php
- $sql_pquery = "select distinct VilleA from VOLS";
+ $sql_pquery = "select distinct VilleA from VOLS order by VilleA";
global $connection;
$connection->prepare_query($sql_pquery);
$connection->run_prepared_query();
<form action="index.php" id="modify" method="post">
<input type="hidden" name="form" value="modify" />
<input type="hidden" name="flight_id" value="<?php echo $rows[0]['NumVol'] ?>" />
+ <input type="hidden" name="previous_class_name" value="<?php echo $rows[0]['Classe'] ?>" />
<label> Nombre de place(s) : </label>
<input type="number" name="nb_place" min="1" max="9" value="<?php echo $rows[0]['NbPlaces'] ?>" required/>
<label> Classe : </label>
<select size="1" name="class_name" required>
<optgroup label="Sélectionner une classe">
<?php
- $sql_pquery = "select distinct Classe from DEFCLASSES where NumVol = ?";
+ $sql_pquery = "select distinct Classe from DEFCLASSES where NumVol = ? order by Classe";
global $connection;
$connection->prepare_query($sql_pquery);
$connection->prepared_query_bind_param("s", array($flight_id));
<select size="1" name="departure_city" required>
<optgroup label="Sélectionner une ville">
<?php
- $sql_pquery = "select distinct VilleD from VOLS";
+ $sql_pquery = "select distinct VilleD from VOLS order by VilleD";
global $connection;
$connection->prepare_query($sql_pquery);
$connection->run_prepared_query();
<select size="1" name="arrival_city" required>
<optgroup label="Sélectionner une ville">
<?php
- $sql_pquery = "select distinct VilleA from VOLS";
+ $sql_pquery = "select distinct VilleA from VOLS order by VilleA";
global $connection;
$connection->prepare_query($sql_pquery);
$connection->run_prepared_query();