-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
99 lines (85 loc) · 2.23 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
require_once 'includes/auth.php';
if (isLoggedIn()) {
header("Location: index.php");
exit();
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
if (attemptLogin($username, $password)) {
header("Location: index.php");
exit();
} else {
$errorMessage = "Invalid username or password.";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login</title>
<style>
/* Add your CSS styles here */
body {
font-family: Arial, sans-serif;
background-color: #f5f8fa;
color: #14171a;
margin: 0;
padding: 0;
}
header {
background-color: #fff;
padding: 1rem;
border-bottom: 1px solid #e1e8ed;
}
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
}
nav ul li {
display: inline;
margin-right: 1rem;
}
nav ul li a {
text-decoration: none;
color: #1da1f2;
font-weight: bold;
}
main {
max-width: 600px;
margin: 2rem auto;
padding: 1rem;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
form label,
form input {
display: block;
margin: 0.5rem 0;
}
</style>
</head>
<body>
<?php include 'includes/header.php'; ?>
<main>
<h1>Login</h1>
<?php if (isset($errorMessage)): ?>
<p style="color: red;"><?php echo htmlspecialchars($errorMessage); ?></p>
<?php endif; ?>
<form action="login.php" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<br>
<input type="submit" value="Login">
</form>
</main>
<?php include 'includes/footer.php'; ?>
</body>
</html>