"; $_SESSION['login_referer'] = $_SERVER['HTTP_REFERER']; redirect("index.php?page=login", 2); } $input_failure = false; $password_failure = false; if (isset($form_street) && !$form_numstreet) { echo "The street number is not valid.
" ; $input_failure = true; } if (isset($form_street) && !$form_postalcode) { echo "The postal code is not valid.
"; $input_failure = true; } if (isset($form_street) && !$form_email) { echo "The email is not valid.
"; $input_failure = true; } if (isset($form_oldpassword) && isset($form_password) && strcmp($form_oldpassword, $form_password) === 0) { echo "Old and new password are the same.
"; $password_failure = true; } if (strcmp($form_password, $form_confirmpassword) !== 0) { echo "Password do not match.
"; $password_failure = true; } if (!empty($form_name) && !empty($form_firstname) && !empty($form_numstreet) && !empty($form_street) && !empty($form_postalcode) && !empty($form_city) && !empty($form_email) && !$input_failure && $is_logged_in) { global $connection; $client_id = get_client_id($_SESSION['email']); $sql_pquery = "update CLIENTS set NomCl = ?, PrenomCl = ?, EmailCl = ?, NumRueCl = ?, NomRueCl = ?, CodePosteCl = ?, VilleCl = ? where NumCl = ?"; $connection->prepare_query($sql_pquery); $connection->prepared_query_bind_param("sssisisi", array($form_name, $form_firstname, $form_email, $form_numstreet, $form_street, $form_postalcode, $form_city, $client_id)); $connection->run_prepared_query(); $connection->close_prepared_query(); echo "You've updated your personal informations, you will be redirected to your account in 3 seconds.
"; redirect("index.php?page=account", 3); } elseif (!empty($form_oldpassword) && !empty($form_password) && !empty($form_confirmpassword) && !$password_failure && $is_logged_in) { if (chk_password($_SESSION['email'], $form_oldpassword)) { global $connection; $client_id = get_client_id($_SESSION['email']); $hashed_password = password_hash($form_password, PASSWORD_DEFAULT); $sql_pquery = "update CLIENTS set PasswordCl = ? where NumCl = ?"; $connection->prepare_query($sql_pquery); $connection->prepared_query_bind_param("si", array($hashed_password, $client_id)); $connection->run_prepared_query(); $connection->close_prepared_query(); echo "You've successfully updated your password.
"; redirect("index.php?page=account", 3); } else { echo "Your old password is incorrect.
"; redirect("index.php?page=account&action=modifypassword", 3); } } else { echo "There's a required non filled field or the input in a field do not match the required pattern.
"; echo "Retour"; } ?>