-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.php
239 lines (203 loc) · 6.34 KB
/
admin.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<?php
if(!(isset($_COOKIE['admin_userid']) && isset($_COOKIE['admin_password']))){
echo "<script>alert('You Need To Login To Access This Page'); window.location.href = 'adminlogin.php';</script>";
exit;
} else {
$conn = mysqli_connect("localhost", "root", "", "book_store");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="IMAGES/ADMIN.png"/>
<title>Admin</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<link href='https://fonts.googleapis.com/css?family=Cantarell' rel='stylesheet'>
<style>
.container {
margin-top: 50px;
}
img {
height: 200px;
width: 200px;
border-radius: 100px;
outline: 1px dotted black;
outline-offset: 5px;
}
.text {
display: flex;
align-items: center;
}
.text p {
font-size: 25px;
margin-left:auto;
margin-right:auto;
font-family: 'Cantarell';
}
.card {
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
width: 280px;
height: 170px;
margin-right: auto;
margin-left: auto;
margin-top:110px;
border-radius: 20px;
margin-bottom:60px;
box-shadow: rgba(0, 0, 0, 0.25) 0px 25px 50px -12px;
}
.buttontext {
margin-top: 10px;
height: 50px;
border-bottom: 1px solid black;
font-family: 'VT323', monospace;
font-size: 20px;
letter-spacing: 1px;
padding-bottom: 60px;
}
.button {
margin-top: 15px;
position: absolute;
margin-left: 28%;
margin-right: 22%;
font-family: "JetBrains Mono", monospace;
letter-spacing: 1px;
font-size: 25px;
}
.btn {
margin-right: 15px;
}
.homePageButton {
margin-top: 80px;
}
@media (max-width: 991.98px) {
img {
height: 100px;
width: 100px;
}
.text {
margin-top: 60px;
}
.text p{
margin-bottom:0px;
font-size: 18px;
margin-left:auto;
margin-right:auto;
}
.card {
display: flex;
flex-direction: column;
align-items: center;
margin-top:50px;
}
.buttontext {
margin-top: 20px;
margin-bottom: 20px;
}
.button {
margin-top: 20px;
}
}
</style>
</head>
<body>
<?php
if($conn){
$sql = "SELECT userid FROM admin WHERE email = '". $_COOKIE["admin_userid"] ."' OR userid = '". $_COOKIE["admin_userid"] . "';";
$result = mysqli_query($conn,$sql);
if($result){
$row = mysqli_fetch_assoc($result);
$a = scandir("./PROFILES");
$c = 0;
foreach ($a as $item=>$name) {
if (str_contains($name, ".jpg")) {
$c++;
}
}
$randomnum = rand(1,$c);
}
}
?>
<div class="container">
<div class="row">
<div class="col-12 col-md-6 text-center">
<img src="PROFILES/profile<?php echo $randomnum . ".jpg"; ?>">
</div>
<div class="col-12 col-md-6 text">
<p>Welcome Admin : @<?php echo $row["userid"];?></p>
</div>
</div>
</div>
<!-- for other options -->
<div class="container">
<div class="row">
<div class="col-12 col-md-6">
<!-- container -->
<div class="card text-center card-body">
<div class="buttontext">
<p class="card-text">Add Book</p>
</div>
<div class="button">
<button class="btn btn-outline-dark homePageButton" id="addBook">Add</button>
</div>
</div>
</div>
<div class="col-12 col-md-6">
<div class="card text-center card-body">
<!-- container -->
<div class="buttontext">
<p class="card-text">Delete Book</p>
</div>
<div class="button">
<button class="btn btn-outline-dark homePageButton" id="deleteBook">Delete</button>
</div>
</div>
</div>
</div>
<!-- 2nd row -->
<div class="row">
<div class="col-12 col-md-6">
<!-- container -->
<div class="card text-center card-body">
<div class="buttontext">
<p class="card-text">Logout Account</p>
</div>
<div class="button">
<button class="btn btn-outline-dark homePageButton" id="logout">Logout</button>
</div>
</div>
</div>
<div class="col-12 col-md-6">
<div class="card text-center card-body">
<!-- container -->
<div class="buttontext">
<p class="card-text">Home Page</p>
</div>
<div class="button">
<button class="btn btn-outline-dark homePageButton" id="homePage">Home</button>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-fbbOQedDUMZZ5KreZpsbe1LCZPVmfTnH7ois6mU1QK+m14rQ1l2bGBq41eYeM/fS" crossorigin="anonymous"></script>
<script>
document.getElementById("addBook").onclick = function() {
location.href = "addbook.php";
};
document.getElementById("deleteBook").onclick = function() {
location.href = "deletebook.php";
};
document.getElementById("logout").onclick = function() {
location.href = "logoutadmin.php";
};
document.getElementById("homePage").onclick = function() {
location.href = "index.php";
};
</script>
</body>
</html>