-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbook_delete.php
68 lines (56 loc) · 2.19 KB
/
book_delete.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
<?php
require_once 'include/user.php';
require 'librarian_required.php';
$bookID = $_GET['bookID'];
$query = $db->prepare(
'SELECT books.book_id AS bookID, books.name AS bookName
FROM books
WHERE book_id = '.$bookID.'
ORDER BY books.name ASC');
$query->execute();
$book = $query->fetch();
if(empty($book)){
echo '<div class="alert alert-info">Nebyly nalezeny žádné knihy.</div>';
}else{
$bookID = $book['bookID'];
$bookName = $book['bookName'];
};
if ($_SERVER["REQUEST_METHOD"] == "POST") {
#region smazani knihy
if(empty($errors)){
$delQuery=$db->prepare('DELETE FROM books WHERE book_id=?;');
$delQuery->execute(array(
$bookID
));
header('Location: book_list.php');
exit();
}
#endregion smazani knihy
};
$pageTitle="Smazání knihy";
include 'include/header.php';
?>
<div class="row mx-3">
<h2 class="col">Smazání knihy</h2>
</div>
<div class="new_book-form pt-5">
<form method="POST">
<h2 class="text-center mb-4 pl-4">Opravdu chcete tuto knihu smazat z databáze?</h2>
<div class="form-group">
<input id="delete_name" type="text" disabled class="form-control text-center font-weight-bold<?php echo(!empty($errors['delete_name']) ? ' is-invalid' : ''); ?>"
name="delete_name" value="<?php echo ''.htmlspecialchars($book['bookName']).'';?>"/>
<?php
echo (!empty($errors['delete_name'])?'<div class="invalid-feedback">'.$errors['delete_name'].'</div>':'');
?>
</div>
<div class="form-group">
<div class="input-group">
<a href="book_list.php" class="col btn btn-outline-secondary mr-2">Zrušit</a>
<button type="submit" class="btn btn-danger col form-control ml-2">Smazat</button>
</div>
</div>
</form>
</div>
<?php
include 'include/footer.php';
?>