-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
182 lines (161 loc) · 4.66 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
session_start();
$error_message = "";
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
$conn = mysqli_connect('localhost', 'root', '', 'beer');
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$query = "SELECT * FROM admin_beer WHERE username='$username' AND password='$password'";
$result = mysqli_query($conn, $query);
if (!$result) {
die("Query failed: " . mysqli_error($conn));
}
if (mysqli_num_rows($result) === 1) {
$_SESSION['username'] = $username;
header('Location: A.php');
exit();
} else {
$error_message = "Invalid username or password";
}
mysqli_close($conn);
}
// Check if error message is set and display it
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Head content here -->
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Open Sans", sans-serif;
}
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
width: 100%;
padding: 0 10px;
}
body::before {
content: "";
position: absolute;
width: 100%;
height: 100%;
background: url("image/admin_main.jpg"), #000;
background-position: center;
background-size: cover;
}
.wrapper {
width: 400px;
border-radius: 8px;
padding: 30px;
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.5);
backdrop-filter: blur(9px);
-webkit-backdrop-filter: blur(9px);
}
form {
display: flex;
flex-direction: column;
}
h2 {
font-size: 6vh;
margin-bottom: 20px;
text-transform: uppercase;
font-family: 'Times New Roman', Times, serif;
color: #fff;
}
.input-field {
position: relative;
border-bottom: 2px solid #ccc;
margin: 15px 0;
}
.input-field label {
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
color: #fff;
font-size: 16px;
pointer-events: none;
transition: 0.15s ease;
}
.input-field input {
width: 100%;
height: 40px;
background: transparent;
border: none;
outline: none;
font-size: 16px;
color: #fff;
}
.input-field input:focus~label,
.input-field input:valid~label {
font-size: 2vh;
top: 1vh;
transform: translateY(-120%);
}
.show_password {
display: flex;
align-items: center;
flex-direction: row;
justify-content: start;
margin: 25px 0 35px 0;
color: #fff;
}
#showPasswordCheckbox {
accent-color: #fff;
}
.show_password p {
margin-left: 8px;
}
button {
background: #fff;
color: #000;
font-weight: 600;
border: none;
padding: 12px 20px;
cursor: pointer;
border-radius: 3px;
font-size: 16px;
border: 2px solid transparent;
transition: 0.3s ease;
}
button:hover {
color: #fff;
border-color: #fff;
background: rgba(255, 255, 255, 0.15);
}
</style>
</head>
<body>
<div class="wrapper">
<form method="POST" action="login.php">
<!-- Form fields -->
<div class="input-field">
<input type="text" name="username" id="username" required>
<label>Enter Your username</label>
</div>
<div class="input-field">
<input type="password" name="password" id="password" required>
<label>Enter Your Password</label>
</div>
<?php if (!empty($error_message)): ?>
<div id="error-message" style="color: red; margin-top: 10px;"><?php echo $error_message; ?></div>
<?php endif; ?>
<div class="show_password">
<input type="checkbox" id="showPasswordCheckbox">
<p>Show Password</p>
</div>
<button type="submit">LOG IN</button>
</form>
</div>
</body>
</html>