Add password change feature.
[Project_webapp.git] / includes / search.php
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e2503d96536f5e1988e5a485cf3b77d09ef5595d 100644 (file)
@@ -0,0 +1,82 @@
+<?php
+$action = filter_input(INPUT_GET, "action", FILTER_SANITIZE_STRING);
+?>
+<h1> Rechercher un vol <?php if ($action === "return_flight") { echo "retour"; } ?></h1>
+
+<?php
+
+$return_flight_departure_city = "";
+$return_flight_arrival_city = "";
+$return_flight_departure_date = "";
+$oDepartureDate = new DateTime("now");
+if ($action === "return_flight") {
+    if (isset($_SESSION['return_flight_departure_city'])) $return_flight_departure_city = $_SESSION['return_flight_departure_city'];
+    if (isset($_SESSION['return_flight_arrival_city'])) $return_flight_arrival_city = $_SESSION['return_flight_arrival_city'];
+    if (isset($_SESSION['return_flight_departure_date'])) {
+        $return_flight_departure_date = $_SESSION['return_flight_departure_date'];
+        $oDepartureDate = new DateTime($return_flight_departure_date);
+    }
+}
+
+?>
+
+<form action="index.php" id="search" method="post">
+ <input type="hidden" name="form" value="search" />
+ <?php if ($action === "return_flight") echo "<input type=\"hidden\" name=\"action\" value=\"return_flight\" />" ?>
+ <input type="hidden" name="date_now" value="<?php echo date('Y-m-d\TH:i', time() - 600); ?>" />
+ <label> De&#769;part : Ville -> </label>
+ <select size="1" name="departure_city" required>
+  <optgroup label="Se&#769;lectionner une ville">
+ <?php
+ $sql_pquery = "select distinct VilleD from VOLS";
+ global $connection;
+ $connection->prepare_query($sql_pquery);
+ $connection->run_prepared_query();
+ $connection->get_pquery_result();
+ $cities = $connection->get_result_array();
+ $connection->close_prepared_query();
+ foreach ($cities as $city) {
+     if (strcmp($city[0], $return_flight_departure_city) === 0) {
+         echo "<option value=\"$city[0]\" selected>$city[0]</option>\n";
+     } else {
+         echo "<option value=\"$city[0]\">$city[0]</option>\n";
+     }
+ }
+ ?>
+  </optgroup>
+ </select>
+ <label> Date -> </label>
+ <input type="datetime-local" name="departure_date" value="<?php echo $oDepartureDate->format('Y-m-d\TH:i'); ?>" required/>
+ <label> Arrive&#769;e : Ville -> </label>
+ <select size="1" name="arrival_city" required>
+  <optgroup label="Se&#769;lectionner une ville">
+ <?php
+ $sql_pquery = "select distinct VilleA from VOLS";
+ global $connection;
+ $connection->prepare_query($sql_pquery);
+ $connection->run_prepared_query();
+ $connection->get_pquery_result();
+ $cities = $connection->get_result_array();
+ $connection->close_prepared_query();
+ foreach ($cities as $city) {
+     if (strcmp($city[0], $return_flight_arrival_city) === 0) {
+         echo "<option value=\"$city[0]\" selected>$city[0]</option>\n";
+     } else {
+         echo "<option value=\"$city[0]\">$city[0]</option>\n";
+     }
+ }
+ ?>
+  </optgroup>
+ </select>
+ <label> Date -> </label>
+ <input type="datetime-local" name="arrival_date" />
+ <input type="submit" value="Rechercher">
+</form>
+<br>
+
+<?php
+// Unset all used session variables
+unset($_SESSION['return_flight_departure_city']);
+unset($_SESSION['return_flight_arrival_city']);
+unset($_SESSION['return_flight_departure_date']);
+?>