-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
44 lines (38 loc) · 1.32 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
<?php
include 'core/init.php';
include 'includes/overall/overall_header.php';
if ( ! empty($_POST)) {
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username) || empty($password)) {
$errors[] = 'You need to enter a user name and password';
} else if (user_exists($username) === false) {
$errors[] = 'That user name does not exist. Please click Register below.';
} else if (is_user_active($username) === false) {
$errors[] = 'Please check your email to activate your account';
} else {
if (strlen($_POST['password']) <= 7) {
$errors[] = 'Your password must be at least 8 characters.';
} else if (strlen($_POST['password']) >= 25) {
$errors[] = 'Your password must be less than 25 characters.';
}
$login = login($username, $password);
if ($login === false) {
$errors[] = 'That username and password combination is incorrect.';
} else {
$_SESSION['user_id'] = $login; //set the user session
echo '<meta HTTP-EQUIV="REFRESH" content="0; url=index.php">'; //redirect to home
exit();
}
}
//print_r($errors);
} else {
$errors[] = 'No data recieved';
}
if (empty($errors) === false) {
print "<h2>We tried to log you in, but...</h2>";
echo output_errors($errors);
} else logged_in_redirect();
//echo output_errors($errors);
include 'includes/overall/overall_footer.php';
?>