Commit | Line | Data |
---|---|---|
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"); | |
12 | if ($action === "return_flight") { | |
22f1dc64 JB |
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 | ?> | |
33eb6f2a | 22 | |
a96fefe1 JB |
23 | <form action="index.php" id="search" method="post"> |
24 | <input type="hidden" name="form" value="search" /> | |
22f1dc64 | 25 | <?php if ($action === "return_flight") echo "<input type=\"hidden\" name=\"action\" value=\"return_flight\" />" ?> |
a2f7a729 | 26 | <input type="hidden" name="date_now" value="<?php echo date('Y-m-d\TH:i', time() - 600); ?>" /> |
a96fefe1 | 27 | <label> Départ : Ville -> </label> |
a2f7a729 JB |
28 | <select size="1" name="departure_city" required> |
29 | <optgroup label="Sé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) { | |
22f1dc64 JB |
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 | } | |
a2f7a729 JB |
44 | } |
45 | ?> | |
46 | </optgroup> | |
47 | </select> | |
a96fefe1 | 48 | <label> Date -> </label> |
22f1dc64 | 49 | <input type="datetime-local" name="departure_date" value="<?php echo $oDepartureDate->format('Y-m-d\TH:i'); ?>" required/> |
a96fefe1 | 50 | <label> Arrivée : Ville -> </label> |
a2f7a729 JB |
51 | <select size="1" name="arrival_city" required> |
52 | <optgroup label="Sé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) { | |
22f1dc64 JB |
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 | } | |
a2f7a729 JB |
67 | } |
68 | ?> | |
69 | </optgroup> | |
70 | </select> | |
a96fefe1 | 71 | <label> Date -> </label> |
a2f7a729 | 72 | <input type="datetime-local" name="arrival_date" /> |
0a87f453 | 73 | <input type="submit" value="Rechercher"> |
a96fefe1 | 74 | </form> |
01135b89 | 75 | <br> |
22f1dc64 JB |
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 | ?> |