-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.edit.books.php
More file actions
330 lines (275 loc) · 14.3 KB
/
admin.edit.books.php
File metadata and controls
330 lines (275 loc) · 14.3 KB
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<?php
session_start();
include_once 'includes/dbh.inc.php';
include_once 'includes/functions.inc.php';
if (isset($_GET['book'])) {
$bookId = $_GET ['book'];
$sql = "SELECT * FROM books WHERE booksId = ?;";
if (!$stmt = mysqli_stmt_init($conn)) {
header('location: admin.php?error=stmtinitfailed');
exit();
}
if (!mysqli_stmt_prepare ($stmt, $sql)) {
header ("Location:admin.php?error=stmtpreparefailed");
exit();
}
if (!mysqli_stmt_bind_param($stmt, "i", $bookId)) {
header('location: admin.php?error=stmtparambindfailed');
exit();
}
mysqli_stmt_execute($stmt);
if ($result = mysqli_stmt_get_result($stmt)) {
if ($row = mysqli_fetch_assoc($result)) {
$bookName = $row['booksName'];
$bookAuthor = $row['booksAuthor'];
$bookCategory = $row['booksCategory'];
$bookBid = $row['booksBid'];
$description1 = $row['booksDescription_1'];
$description2 = $row['booksDescription_2'];
$image = $row['booksImage'];
}
}
}
?>
<html>
<head?>
<!--boostrap-->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
crossorigin="anonymous"></script>
<title>Books</title>
<style type="text/css">
.form-control {
width:400px;
}
.form1 {
margin:0 540px;
}
label {
color: white;
margin-top: 10px;
}
/*--------------------search bar----------------------*/
input[type="text"] {
width: 250px;
transition: width .35s ease-in-out, .35s ease-in-out;
box-sizing: border-box;
box-shadow: 0 0 4px gray;
}
input[type="text"]:focus {
width: 410px;
margin-left: -160px;
box-shadow: 0 0 6px orange;
}
#table {
background-color: black;
border-radius: 6px;
color: white;
width: 325px;
box-shadow: 0 0px 16px orange;
}
</style>
</head>
<body>
<!--...................................................................
..........................Admin Navigation Bar.............................
....................................................................-->
<?php
include_once 'admin.navigation.bar.php';
?>
<div style="background-image: url('Image/admin4.jpg'); background-size: cover; background-repeat :no-repeat;">
<br>
<div class = "row">
<div class="col-5"></div>
<div class="col-6">
<div id="search">
<form class="d-flex" type="search" method="post">
<input class="form-control me-2" type="text" name="search" placeholder="Search Books">
<button class="btn btn btn-dark" type="submit" name="searchsubmit">Search</button>
</form>
<table id="table" cellpadding="12">
<?php
if (isset($_POST['searchsubmit'])) {
$search = $_POST ['search'];
$sql = "SELECT * FROM books WHERE booksName LIKE '%$search%' OR booksAuthor LIKE '%$search%'";
$result = mysqli_query($conn, $sql);
if ($result) {
if (mysqli_num_rows ($result)<5) {
echo '<thead>
<tr style="color: orange;">
<th>Book</th>
<th>Author</th>
<th>Category</th>
</tr>
</thead>';
while ($row = mysqli_fetch_assoc ($result)) {
echo '<tbody>
<tr>
<td><a href = "admin.edit.books.php?book='.$row['booksId'].'">'.$row['booksName'].'</a></td>
<td>'.$row['booksAuthor'].'</td>
<td>'.$row['booksCategory'].'</td>
</tr>
</tbody>';
}
}
else {
echo '<thead>
<tr>
<td style="color: orange; font-weight: bold;">No results found</td>
</tr>
</thead><br>';
}
}
}
?>
</table>
</div>
</div>
</div>
<?php if (isset($_GET['book'])) { ?>
<form class="needs-validation border p-4 row" action="includes/bookedit.php?book=<?php echo $_GET['book'] ?>" method="post" enctype="multipart/form-data" style="border-radius: 12px; margin-left: 30px; margin-right: 30px;">
<h3 style="color: white;">Update Book</h3>
<!--...........................Book Name.................................-->
<div class="col-3 mt-3">
<label for="name" class="form-label">Book Name</label>
<input required type="text" class="form-control" id="book_name" name="book_name" value="<?php echo $bookName; ?>" placeholder="<?php echo $bookName; ?>">
</div>
<div class="col-9"> <!--for space--> </div>
<!--...........................Book Author.................................-->
<div class="col-3 mt-3">
<label for="name" class="form-label">Book Author</label>
<input required type="text" class="form-control" id="book_author" name="book_author" value="<?php echo $bookAuthor; ?>" placeholder="<?php echo $bookAuthor; ?>">
</div>
<div class="col-9"> <!--for space--> </div>
<!--..........................Book Category..............................-->
<div class="col-3 mt-3">
<label for="position" class="form-label">Category</label>
<select required class="form-select" id="category" name="category">
<option value="<?php echo $bookCategory; ?>"><?php echo $bookCategory; ?></option>
<option value="Fantasy">Fantasy</option>
<option value="Mystery / Thriller">Mystery/Thriller</option>
<option value="Action and Adventure">Action & Adventure</option>
<option value="Classics">Classics</option>
<option value="Humor">Humor</option>
<option value="Romance">Romance</option>
<option value="Self-Help">Self-Help</option>
<option value="Realistic Fiction">Realistic Fiction</option>
<option value="Science Fiction">Science Fiction</option>
<option value="Historical Fiction">Historical Fiction</option>
<option value="Biography / Memoir">Biography/Memoir</option>
<option value="Graphic Novel">Graphic Novel</option>
<option value="Children's Literature">Children's Literature</option>
<option value="Sports">Sports</option>
<option value="Western">Western</option>
<option value="Young Adult">Young Adult</option>
</select>
</div>
<div class="col-9"> <!--for space--> </div>
<!--.........................Book Id...............................-->
<div class="col-3 mt-3">
<label for="username" class="form-label">Book ID</label>
<input required type="text" class="form-control" id="book_id" name="book_id" value="<?php echo $bookBid; ?>" placeholder="<?php echo $bookBid; ?>">
</div>
<div class="col-9"> <!--for space--> </div>
<!--........................Description 1..............................-->
<div class="col-3 mt-3">
<label for="username" class="form-label">About Book</label>
<input required type="text" class="form-control" id="about" name="about" value="<?php echo $description1; ?>" placeholder="<?php echo $description1; ?>">
</div>
<div class="col-9"> <!--for space--> </div>
<!--........................Description 2...............................-->
<div class="col-3 mt-3">
<label for="username" class="form-label">Description</label>
<input required type="text" class="form-control" id="description" name="description" value="<?php echo $description2; ?>" placeholder="<?php echo $description2; ?>">
</div>
<div class="col-9"> <!--for space--> </div>
<!--..........................Book Image................................-->
<div class="col-3 mt-3">
<label><h6><b>Book Image</b></h6></label>
<input required class="form-control row" type="file" name="file" value="<?php echo $image; ?>" placeholder="<?php echo $image; ?>">
</div>
<div class="col-9"> <!--for space--> </div>
<!--.........................Submit Button..........................-->
<button class="btn btn-outline-warning col-1 mt-5" type="submit" id="submit" name="formsubmit" style="margin-left: 12px;">Update</button>
</form>
<?php } else { ?>
<form class="needs-validation border p-4 row" action="includes/bookedit.php" method="post" enctype="multipart/form-data" style="border-radius: 12px; margin-left: 30px; margin-right: 30px;">
<h3 style="color: white;">Update Book</h3>
<!--...........................Book Name.................................-->
<div class="col-3 mt-3">
<label for="name" class="form-label">Book Name</label>
<input required type="text" class="form-control" id="book_name" name="book_name" placeholder="Book Name">
</div>
<div class="col-9"> <!--for space--> </div>
<!--...........................Book Author.................................-->
<div class="col-3 mt-3">
<label for="name" class="form-label">Book Author</label>
<input required type="text" class="form-control" id="book_author" name="book_author" placeholder="Book Author">
</div>
<div class="col-9"> <!--for space--> </div>
<!--..........................Book Category..............................-->
<div class="col-3 mt-3">
<label for="position" class="form-label">Category</label>
<select required class="form-select" id="category" name="category">
<option value="none">Select Category</option>
<option value="Fantasy">Fantasy</option>
<option value="Mystery / Thriller">Mystery/Thriller</option>
<option value="Action and Adventure">Action & Adventure</option>
<option value="Classics">Classics</option>
<option value="Humor">Humor</option>
<option value="Romance">Romance</option>
<option value="Self-Help">Self-Help</option>
<option value="Realistic Fiction">Realistic Fiction</option>
<option value="Science Fiction">Science Fiction</option>
<option value="Historical Fiction">Historical Fiction</option>
<option value="Biography / Memoir">Biography/Memoir</option>
<option value="Graphic Novel">Graphic Novel</option>
<option value="Children's Literature">Children's Literature</option>
<option value="Sports">Sports</option>
<option value="Western">Western</option>
<option value="Young Adult">Young Adult</option>
</select>
</div>
<div class="col-9"> <!--for space--> </div>
<!--.........................Book Id...............................-->
<div class="col-3 mt-3">
<label for="username" class="form-label">Book ID</label>
<input required type="text" class="form-control" id="book_id" name="book_id" placeholder="Book ID">
</div>
<div class="col-9"> <!--for space--> </div>
<!--........................Description 1..............................-->
<div class="col-3 mt-3">
<label for="username" class="form-label">About Book</label>
<input required type="text" class="form-control" id="about" name="about" placeholder="About the Book">
</div>
<div class="col-9"> <!--for space--> </div>
<!--........................Description 2...............................-->
<div class="col-3 mt-3">
<label for="username" class="form-label">Description</label>
<input required type="text" class="form-control" id="description" name="description" placeholder="Description">
</div>
<div class="col-9"> <!--for space--> </div>
<!--..........................Book Image................................-->
<div class="col-3 mt-3">
<label><h6><b>Book Image</b></h6></label>
<input required class="form-control row" type="file" name="file" placeholder="Book Image">
</div>
<div class="col-9"> <!--for space--> </div>
<!--.........................Submit Button..........................-->
<button class="btn btn-outline-warning col-1 mt-5" type="submit" id="submit" name="formsubmit" style="margin-left: 12px;">Update</button>
</form>
<?php } ?>
<br>
</div>
<!--...................................................................
..................................Footer...............................
....................................................................-->
<?php
include_once 'Footer/footer.php';
?>
</body>
</html>