/
login.php
executable file
·53 lines (34 loc) · 1.07 KB
/
login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
//Include the common file
require_once('common.php');
//Check if the user is logged in
if ($authentication->logged_in() && $authentication->is_group('customer')) header("Location: account.php");
//Check if the form has been submitted
if (isset($_POST['login'])) {
$validate->email($_POST['email'], 'Email address not valid.');
$validate->required($_POST['password'], 'Enter your password.');
if (!$error->has_errors()) {
$remember = false;
if (isset($_POST['remember']))
$remember = true;
if ($authentication->login($_POST['email'], $_POST['password'], $remember))
header("Location: account.php");
else
$tpl->set('failed', true);
} else {
$tpl->set('failed', true);
}
}
//Check if the form has been submitted
if (isset($_POST['reset_password'])) {
$validate->email($_POST['email'], 'Email address not valid.');
if (!$error->has_errors()) {
if ($authentication->new_password($_POST['email']))
$tpl->set('success', true);
else
$tpl->set('failed', true);
}
}
//Display the template
$tpl->display('login');
?>