Fix the SQL for reservations class modification.
[Project_webapp.git] / includes / modify.php
index aeb9741444e0b39a1df6028e9bab8c5f5b6f83ee..045d84acfe511c93b11a0cc955c09d917311b9cc 100644 (file)
@@ -1,8 +1,16 @@
 <?php
+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);
+    include('footer.html');
+    exit();
+}
 $flight_id = filter_input(INPUT_GET, "flight_id", FILTER_SANITIZE_STRING);
 $class_name = filter_input(INPUT_GET, "class_name", FILTER_SANITIZE_STRING);
 $client_id = get_client_id($_SESSION['email']);
-echo "<h1> Modification de la re&#769;servation sur le vol $flight_id</h2>\n";
+echo "<h1> Modification de la re&#769;servation sur le vol $flight_id </h2>\n";
 global $connection;
 $sql_pquery = "select NumCl, NumVol, Classe, NbPlaces
                from RESERVATIONS
@@ -17,13 +25,14 @@ $connection->close_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="Se&#769;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));