-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
50 lines (50 loc) · 1.38 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
<?php
if (isset($_POST["submit"]) && $_SERVER["REQUEST_METHOD"] == "POST") {
require_once "./util/rb_config.php";
$username = $_POST["username"];
$password = $_POST["password"];
$user = R::findOne("user", "username = ?", [$username]);
if ($user) {
if (password_verify($password, $user->password)) {
require_once "./util/session.php";
$_SESSION["user_id"] = $user->id;
header("Location: index.php");
exit;
}
} else {
?>
<p class="msg msg--error msg--float">Incorrect username/password</p>
<?php
}
}
?>
<!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.0">
<title>Log in</title>
<?php require_once "component/head.php"; ?>
</head>
<body>
<form action="login.php" method="post" class="center_of_page">
<fieldset>
<legend>Log in</legend>
<label for="username">
Username:
<input type="text" name="username" id="username">
</label>
<br>
<label for="password">
Password:
<input type="password" name="password" id="password">
</label>
<br>
<input type="submit" name="submit" value="Log in">
<br>
No account? <a href="register.php">Register</a>
</fieldset>
</form>
</body>
</html>