forked from J2TEAM/php-sarahah-clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
84 lines (75 loc) · 3.36 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/* Developed by Juno_okyo */
define('ROOT', __DIR__ . DIRECTORY_SEPARATOR);
require_once ROOT . 'config.php';
session_start();
// Check login status
if (isset($_SESSION['logged_in'])) {
header('Location: messages.php', TRUE, 302);
exit;
}
$error = FALSE;
if (isset($_POST['username'], $_POST['password']) && ! empty($_POST['username']) && ! empty($_POST['password'])) {
if ($_POST['username'] === ADMIN_USERNAME && password_verify($_POST['password'], ADMIN_PASSWORD)) {
$_SESSION['logged_in'] = TRUE;
// Redirect to the messages page
header('Location: messages.php', TRUE, 302);
exit;
} else {
$error = TRUE;
}
}
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Juno_okyo">
<meta name="copyright" content="J2TEAM">
<title>Sarahah clone by Juno_okyo</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto">
<link rel="stylesheet" href="css/main.css">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<?php include(ROOT . '_templates/navbar.php'); ?>
<div class="container" style="width: 600px;">
<div class="row">
<div class="col-xs-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">User Login</h3>
</div>
<div class="panel-body">
<form action="login.php" method="POST" role="form">
<div class="form-group">
<label for="username"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Username</label>
<input type="text" class="form-control" name="username" id="username" placeholder="Your username..." autofocus required>
</div>
<div class="form-group">
<label for="password"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span> Password</label>
<input type="password" class="form-control" name="password" id="password" placeholder="Your password..." required>
</div>
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-log-in" aria-hidden="true"></span> Login</button>
<button type="reset" class="btn btn-danger"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Reset</button>
</form>
</div>
</div>
<?php if ($error): ?>
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>Error!</strong> Your username or password is incorrect.
</div>
<?php endif; ?>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>