-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreserve.php
53 lines (43 loc) · 1.4 KB
/
reserve.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
<?php
include 'header.php';
$user = new User();
$books = new Books();
$user->authenticate();
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<title>autoLib - Reserve a Book</title>
</head>
<body>
<?php
/* Use PHP and the basename method.
By using this and the __FILE__ arguement we can figure out which page is being visited, so the menu.php file can figure out which pages are to be displayed as active. */
$pageName = basename(__FILE__);
include 'menu.php';
?>
<div style="margin-left:25%;padding:1px 16px;height:100%;">
<h2><div class="right"><a href="logout.php">Logout</a></div>Reserve a Book</h2>
<hr/>
<?php
if(isset($_GET["isbn"]) && !empty($_GET["isbn"])) {
echo '<h3>Thank you! You have reserved the following:</h3>';
$stmt = $connection->prepare("SELECT * FROM books WHERE isbn = ? LIMIT 1");
$stmt->bind_param("s", $_GET["isbn"]);
$stmt->execute();
$stmt->bind_result($ISBN, $bookTitle, $author, $edition, $year, $category, $reserved);
while($stmt->fetch()) {
echo '<p><strong><u>ISBN</u></strong>: '.$ISBN.'</p>';
echo '<p><strong><u>Book Title:</u></strong> '.$bookTitle.'</p>';
echo '<p><strong><u>Author:</u></strong> '.$author.'</p>';
}
$books->reserveBook($_GET["isbn"], $_SESSION["username"]);
}
?>
<h3>Availible Books</h3>
<?php $books->displayAvailibleBooks(); ?>
</div>
<?php include 'footer.php'; ?>
</body>
</html>