Add return flight booking cinematic and personal informations editing.
[Project_webapp.git] / includes / formaccount.php
1 <?php
2 $form_name = filter_input(INPUT_POST, "name", FILTER_SANITIZE_STRING);
3 $form_firstname = filter_input(INPUT_POST, "firstname", FILTER_SANITIZE_STRING);
4 $form_numstreet = filter_input(INPUT_POST, "numstreet", FILTER_VALIDATE_INT);
5 $form_street = filter_input(INPUT_POST, "street", FILTER_SANITIZE_STRING);
6 $form_postalcode = filter_input(INPUT_POST, "postalcode", FILTER_VALIDATE_INT);
7 $form_city = filter_input(INPUT_POST, "city", FILTER_SANITIZE_STRING);
8 $form_email = filter_input(INPUT_POST, "email", FILTER_VALIDATE_EMAIL);
9
10 $input_failure = false;
11
12 if (!$form_numstreet) {
13 echo "The street number is not valid. <br>" ;
14 $input_failure = true;
15 }
16 if (!$form_postalcode) {
17 echo "The postal code is not valid. <br>";
18 $input_failure = true;
19 }
20 if (!$form_email) {
21 echo "The email is not valid. <br>";
22 $input_failure = true;
23 }
24
25 if (!empty($form_name) && !empty($form_firstname) && !empty($form_numstreet) && !empty($form_street) &&
26 !empty($form_postalcode) && !empty($form_city) && !empty($form_email) &&
27 !$input_failure) {
28 global $connection;
29 $client_id = get_client_id($_SESSION['email']);
30 $sql_pquery = "update CLIENTS
31 set NomCl = ?, PrenomCl = ?, EmailCl = ?, NumRueCl = ?, NomRueCl = ?, CodePosteCl = ?, VilleCl = ?
32 where NumCl = ?";
33 $connection->prepare_query($sql_pquery);
34 $connection->prepared_query_bind_param("sssisisi", array($form_name, $form_firstname, $form_email, $form_numstreet, $form_street, $form_postalcode, $form_city, $client_id));
35 $connection->run_prepared_query();
36 $connection->close_prepared_query();
37 echo "You've updated your personal informations, you will be redirected to your account in 3 seconds. <br>";
38 redirect("index.php?page=account", 3);
39
40 } else {
41 echo "There's a required non filled field or the input in a field do not match the required pattern. <br>";
42 echo "<a href=\"javascript:history.go(-1)\">Retour</a>";
43 }
44 ?>