Add the reservation modification feature.
[Project_webapp.git] / includes / formmodify.php
diff --git a/includes/formmodify.php b/includes/formmodify.php
new file mode 100644 (file)
index 0000000..20e53f6
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+$form_flight_id = filter_input(INPUT_POST, "flight_id", FILTER_SANITIZE_STRING);
+$form_nb_place = filter_input(INPUT_POST, "nb_place", FILTER_VALIDATE_INT);
+$form_class_name = filter_input(INPUT_POST, "class_name", FILTER_SANITIZE_STRING);
+
+global $connection;
+$client_id = get_client_id($_SESSION['email']);
+$sql_pquery = "update RESERVATIONS
+                   set NbPlaces = ?, Classe = ?
+                   where NumCl = ? and NumVol = ?";
+$connection->prepare_query($sql_pquery);
+$connection->prepared_query_bind_param("isis", array($form_nb_place, $form_class_name, $client_id, $form_flight_id));
+$connection->run_prepared_query();
+$connection->close_prepared_query();
+echo "Modifications enregistre&#769;es. <br>";
+redirect("index.php?page=reservations", 3);
+?>