- !empty($form_postalcode) && !empty($form_town) && !empty($form_email) && !empty($form_password)){
- global $connection;
- $sql_pquery = "select count(NumCl) from CLIENTS where EmailCl = ?";
- $stmt = $connection->prepare_query($sql_pquery);
- $stmt->bind_param("s", $form_email);
- //$connection->prepared_query_bind_param("s", $form_email);
- $connection->run_prepared_query();
- $connection->close_prepared_query();
+ !empty($form_postalcode) && !empty($form_city) && !empty($form_email) && !empty($form_password) &&
+ !$error_numstreet && !$error_postalcode && !$error_email && !$error_password) {
+ if (!chk_account($form_email)) {
+ global $connection;
+ $hashed_password = password_hash($form_password, PASSWORD_DEFAULT);
+ $sql_pquery = "insert into CLIENTS (NomCl, PrenomCl, EmailCl, PasswordCl, NumRueCl, NomRueCl, CodePosteCl, VilleCl)
+ values (?, ?, ?, ?, ?, ?, ?, ?)";
+ $connection->prepare_query($sql_pquery);
+ $connection->prepared_query_bind_param("ssssisis", array($form_name, $form_firstname, $form_email, $hashed_password, $form_numstreet, $form_street, $form_postalcode, $form_city));
+ $connection->run_prepared_query();
+ $connection->close_prepared_query();
+ echo "You've successfully registered, you will be redirected to the login form in 3 seconds. <br>";
+ redirect("index.php?page=login", 3);
+ } else {
+ echo "You're already registered, you will be redirected to the login form in 3 seconds. <br>";
+ redirect("index.php?page=login", 3);
+ }
+} else {
+ echo "There's a required non filled field or the input in a field do not match the required pattern. <br>";
+ echo "<a href=\"javascript:history.go(-1)\">Retour</a>";