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