-
Notifications
You must be signed in to change notification settings - Fork 21
/
login.php
56 lines (46 loc) · 1.28 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
54
55
56
<?php
require_once 'core/init.php';
if(Input::exists()) {
if(Token::check(Input::get('token'))) {
$validate = new Validate();
$validation = $validate->check($_POST, array(
'username' => array('required' => true),
'password' => array('required' => true)
));
if($validation->passed()) {
// Login user
$user = new User();
$remember = (Input::get('remember') === 'on') ? true : false;
$login = $user->login(Input::get('username'), Input::get('password'), $remember);
if($login) {
// echo 'Success';
Redirect::to('index.php');
} else {
echo '<p>Sorry, logging in failed';
}
} else {
foreach($validation-errors() as $error) {
echo $error, '<br>';
}
}
}
}
?>
<form action="" method="post">
<div class="field">
<label for="username">Username</label>
<input type="text" name="username" id="username" autocomplete="off" />
</div>
<div class="field">
<label for="password">Password</label>
<input type="passowrd" name="password" id="password" autocomplete="off" />
</div>
<div class="field">
<label for="remember">
<input type="checkbox" name="remember" id="remember" />
Remember me
</label>
</div>
<input type="hidden" name="token" value="<?php echo Token::generate(); ?>" />
<input type="submit" value="login" />
</form>