Add password change feature.
[Project_webapp.git] / includes / search.php
1 <?php
2 $action = filter_input(INPUT_GET, "action", FILTER_SANITIZE_STRING);
3 ?>
4 <h1> Rechercher un vol <?php if ($action === "return_flight") { echo "retour"; } ?></h1>
5
6 <?php
7
8 $return_flight_departure_city = "";
9 $return_flight_arrival_city = "";
10 $return_flight_departure_date = "";
11 $oDepartureDate = new DateTime("now");
12 if ($action === "return_flight") {
13 if (isset($_SESSION['return_flight_departure_city'])) $return_flight_departure_city = $_SESSION['return_flight_departure_city'];
14 if (isset($_SESSION['return_flight_arrival_city'])) $return_flight_arrival_city = $_SESSION['return_flight_arrival_city'];
15 if (isset($_SESSION['return_flight_departure_date'])) {
16 $return_flight_departure_date = $_SESSION['return_flight_departure_date'];
17 $oDepartureDate = new DateTime($return_flight_departure_date);
18 }
19 }
20
21 ?>
22
23 <form action="index.php" id="search" method="post">
24 <input type="hidden" name="form" value="search" />
25 <?php if ($action === "return_flight") echo "<input type=\"hidden\" name=\"action\" value=\"return_flight\" />" ?>
26 <input type="hidden" name="date_now" value="<?php echo date('Y-m-d\TH:i', time() - 600); ?>" />
27 <label> De&#769;part : Ville -> </label>
28 <select size="1" name="departure_city" required>
29 <optgroup label="Se&#769;lectionner une ville">
30 <?php
31 $sql_pquery = "select distinct VilleD from VOLS";
32 global $connection;
33 $connection->prepare_query($sql_pquery);
34 $connection->run_prepared_query();
35 $connection->get_pquery_result();
36 $cities = $connection->get_result_array();
37 $connection->close_prepared_query();
38 foreach ($cities as $city) {
39 if (strcmp($city[0], $return_flight_departure_city) === 0) {
40 echo "<option value=\"$city[0]\" selected>$city[0]</option>\n";
41 } else {
42 echo "<option value=\"$city[0]\">$city[0]</option>\n";
43 }
44 }
45 ?>
46 </optgroup>
47 </select>
48 <label> Date -> </label>
49 <input type="datetime-local" name="departure_date" value="<?php echo $oDepartureDate->format('Y-m-d\TH:i'); ?>" required/>
50 <label> Arrive&#769;e : Ville -> </label>
51 <select size="1" name="arrival_city" required>
52 <optgroup label="Se&#769;lectionner une ville">
53 <?php
54 $sql_pquery = "select distinct VilleA from VOLS";
55 global $connection;
56 $connection->prepare_query($sql_pquery);
57 $connection->run_prepared_query();
58 $connection->get_pquery_result();
59 $cities = $connection->get_result_array();
60 $connection->close_prepared_query();
61 foreach ($cities as $city) {
62 if (strcmp($city[0], $return_flight_arrival_city) === 0) {
63 echo "<option value=\"$city[0]\" selected>$city[0]</option>\n";
64 } else {
65 echo "<option value=\"$city[0]\">$city[0]</option>\n";
66 }
67 }
68 ?>
69 </optgroup>
70 </select>
71 <label> Date -> </label>
72 <input type="datetime-local" name="arrival_date" />
73 <input type="submit" value="Rechercher">
74 </form>
75 <br>
76
77 <?php
78 // Unset all used session variables
79 unset($_SESSION['return_flight_departure_city']);
80 unset($_SESSION['return_flight_arrival_city']);
81 unset($_SESSION['return_flight_departure_date']);
82 ?>