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 $form_password = filter_input(INPUT_POST
, "password", FILTER_SANITIZE_STRING
);
10 $form_confirmpassword = filter_input(INPUT_POST
, "confirmpassword", FILTER_SANITIZE_STRING
);
12 $error_numstreet = false;
13 $error_postalcode = false;
15 $error_password = false;
17 if (!$form_numstreet) {
18 echo "The street number is not valid. <br>" ;
19 $error_numstreet = true;
21 if (!$form_postalcode) {
22 echo "The postal code is not valid. <br>";
23 $error_postalcode = true;
26 echo "The email is not valid. <br>";
29 if (strcmp($form_password, $form_confirmpassword) !== 0) {
30 echo "Password do not match. <br>";
31 $error_password = true;
34 if (!empty($form_name) && !empty($form_firstname) && !empty($form_numstreet) && !empty($form_street) &&
35 !empty($form_postalcode) && !empty($form_city) && !empty($form_email) && !empty($form_password) &&
36 !$error_numstreet && !$error_postalcode && !$error_email && !$error_password) {
37 if (!chk_account($form_email)) {
39 $hashed_password = password_hash($form_password, PASSWORD_DEFAULT
);
40 $sql_pquery = "insert into CLIENTS (NomCl, PrenomCl, EmailCl, PasswordCl, NumRueCl, NomRueCl, CodePosteCl, VilleCl)
41 values (?, ?, ?, ?, ?, ?, ?, ?)";
42 $connection->prepare_query($sql_pquery);
43 $connection->prepared_query_bind_param("ssssisis", array($form_name, $form_firstname, $form_email, $hashed_password, $form_numstreet, $form_street, $form_postalcode, $form_city));
44 $connection->run_prepared_query();
45 $connection->close_prepared_query();
46 echo "You've successfully registered, you will be redirected to the login form in 3 seconds. <br>";
47 redirect("index.php?page=login", 3);
49 echo "You're already registered, you will be redirected to the login form in 3 seconds. <br>";
50 redirect("index.php?page=login", 3);
53 echo "There's a required non filled field or the input in a field do not match the required pattern. <br>";
54 echo "<a href=\"javascript:history.go(-1)\">Retour</a>";