$errors = ' Please put the same password';
                $updateOk = false;
            }
            if (!isset($passwordActual) || sha1($passwordActual) != $currentPwd['password']) {
                $errors = ' Please set Your current password ';
                $updateOk = false;
            }
        }
        if (!$updateOk) {
            http_response_code(400);
            echo json_encode(array('success' => false, "errors" => $errors));
        } else {
            if (!empty($_POST['pwd'])) {
                $_POST['pwd'] = sha1($_POST['pwd']);
                unset($_POST['pwd2']);
                $updateProfil->updateProfil($pdo);
            } else {
                $updateProfil->updateProfilWithoutPwd($pdo);
            }
            $_SESSION['firstname'] = $_POST['firstname'];
            $_SESSION['lastname'] = $_POST['lastname'];
            $_SESSION['gender'] = $_POST['gender'];
            $_SESSION['birthdate'] = $_POST['birthdate'];
            $_SESSION['email'] = $_POST['email'];
            $_SESSION['login'] = $_POST['login'];
            echo json_encode(array('success' => true, "user" => $_POST));
        }
    }
} else {
    header("refresh:0; url=../view/login.php");
}