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