-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
56 lines (35 loc) · 1.01 KB
/
index.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
54
55
56
<?php
/*
* I Have Plans -- Login controller
* @author Steven Dufresne <[email protected]>
* @link http://github.com/StevenDufresne/web-app
* @copyright 2012 Steven Dufresne
* @license BSD-3-Clause <https://github.com/stevendufresne/web-app/BSD-3-CLAUSE-LICENSE.txt>
*/
require_once 'includes/db.inc.php';
require_once 'includes/users.inc.php';
$errors = array();
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
$password = filter_input(INPUT_POST, 'password', FILTER_UNSAFE_RAW);
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
if ( empty($username) ) {
$errors['username'] = true;
}
if ( empty($password) ) {
$errors['password'] = true;
}
if ( empty($errors) ) {
$user_info = user_get($db, $username, $password);
$user_id = $user_info['id'];
$user_name = $user_info['username'];
if ( $user_id ) {
user_sign_in($user_id, $user_name);
header('Location: calendar.php');
exit;
} else {
$errors['no-user'] = true;
}
}
}
include "views/login.html.php"
?>