Commit | Line | Data |
---|---|---|
b5f60f89 JB |
1 | <?php |
2 | $form_email = filter_input(INPUT_POST, "email", FILTER_VALIDATE_EMAIL); | |
3 | $form_password = filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING); | |
4 | ||
5 | if (!$form_email) { | |
a96fefe1 | 6 | echo "The email is not valid. <br>"; |
1f4879b9 | 7 | redirect("index.php?page=login", 3); |
a96fefe1 JB |
8 | } elseif (isset($form_email) && isset($form_password)) { |
9 | if (chk_account($form_email)) { | |
10 | if (chk_password($form_email, $form_password)) { | |
11 | // authentification okay, setup session | |
12 | session_regenerate_id(true); | |
13 | $_SESSION['email'] = $form_email; | |
14 | $_SESSION['IP_address'] = $_SERVER['REMOTE_ADDR']; | |
15 | // redirect to required page | |
16 | echo "You're successfully authenticated. <br>"; | |
17 | redirect("index.php", 3); | |
18 | } else { | |
33eb6f2a | 19 | echo "Your password is incorrect for the account email " . $form_email . ". <br>"; |
a96fefe1 JB |
20 | echo "<a href=\"javascript:history.go(-1)\">Retour</a>"; |
21 | } | |
22 | } else { | |
23 | echo "You do not have an account for the email " . $form_email . ". <br>"; | |
24 | echo "Please register first."; | |
25 | redirect("index.php?page=register", 3); | |
b5f60f89 | 26 | } |
a96fefe1 | 27 | } else { |
1f4879b9 JB |
28 | // didn't authenticate for unknown reason, go back to login form |
29 | echo "Fail to authenticate for unknown reason. <br>"; | |
a96fefe1 | 30 | redirect("index.php?page=login", 3); |
b5f60f89 | 31 | } |
77c2d82c JB |
32 | |
33 | ?> |