-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBooksearch.php
More file actions
147 lines (124 loc) · 5.25 KB
/
Booksearch.php
File metadata and controls
147 lines (124 loc) · 5.25 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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<?php
ob_start();
session_start();
if(!isset($_SESSION['myusername']))
header("location:index.html");
$usid=$_SESSION['ID'];
$ID=substr($usid,0,1);
require 'DBconnect.php';
?>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>Booksearch</title>
<?php require 'style.php'; ?>
<link rel="stylesheet" type="text/css" href="CSS/Menubar.css">
<link rel="stylesheet" type="text/css" href="CSS/butt.css">
</head>
<body style="color: rgb(0, 0, 0); background-color: rgb(195, 223, 239);" alink="#000099" link="#000099" vlink="#990099">
<?php require 'searchbar.php'; ?>
<ul>
<li><a class="nonactive" <?php if($ID=='T') echo 'href="StaffPage.php"'; else echo 'href="StudentPage.php"';?>>Home</a></li>
<li><a href="Notification.php"><?php require 'notificationstyle.php'; ?></a></li>
<li><a href="Message.php"><?php require 'messagestyle.php'; ?></a></li>
<ul style="float: right; list-style-type: none;">
<li><a class="nonactive" href="rules.html">Rules of library</a></li>
<li><a href="Accountsetting.php">Account Settings</a></li>
<li><a <?php if($ID=='T') echo 'href="Stafflogin.php"'; else echo 'href="Studentlogin.php"';?>>Logout</a></li>
</ul>
</ul>
<br>
<table style="width: 95%; height: 750px; text-align: left; margin-left: auto; margin-right: auto;" border="0" cellpadding="1" cellspacing="0">
<tbody>
<tr>
<td style="vertical-align: top;"> <img style="border: 1px solid ; width: 204px; height: 204px; float: left;" alt="User pic" src="userpics/<?php echo $_SESSION['ID']; ?>.jpg" hspace="10" vspace="15"> <br>
<br>
<br>
Name: <?php echo '<span style="font-family: Tahoma; color: red;">'.$_SESSION['myusername'].'</span>'; ?><br>
ID: <?php echo '<span style="font-family: Tahoma; color: red;">'.$_SESSION['ID'].'</span>'; ?><br>
Department: <?php echo '<span style="font-family: Tahoma; color: red;">'.$_SESSION['department'].'</span>'; ?><br>
<br>
<br>
<br>
<span style="font-family: Tahoma;">Fine in your account : <?php echo '<span style="font-family: Tahoma; color: red;">'.$_SESSION['fine'].'</span>'; ?>
</span><br>
<br>
<br>
</td>
<td style="width: 90%; vertical-align: top; background-color: white; text-align: center;">
<br><br><br>
<?php
echo '<hr><big style="font-family: Pristina; color: rgb(255, 102, 102); font-weight: bold;"><big>Books search result</big></big><hr><br><br>';
if(isset($_POST['searchbk'])&&!empty($_POST['searchbk']))
{
$bkname=$_POST['searchbk'];
$sql3="SELECT mainid,author FROM books WHERE name='$bkname'";
$result = mysqli_query($con,$sql3);
$count=mysqli_num_rows($result);
if(! $result )
die('Could not get data: ' . mysqli_error($con));
else if($count!=0)
{
echo '<table style="text-align: left; margin-left: auto; margin-right: auto;" border="0" cellpadding="2" cellspacing="4">
<tbody>
<tr>';
$det = mysqli_fetch_assoc($result);
echo '<td style="width: 264px; height: 350px; vertical-align: top; text-align: center;">
<img style="width: 262px; height: 264px;" alt="book pic" src="bookpics/'.$det['mainid'].'.jpg">
<br>
name: <span style="color: red;">'.$bkname.'</span><br>
Author: <span style="color: red;">'.$det['author'].'</span><br>
<br>
book main_id: <span style="color: red;">'.$det['mainid'].'</span><br>';
$bkid=$det['mainid'];
$sql="CALL Check_Transaction('$bkid','$usid',@flag)";
$result=mysqli_query($con,$sql);
if(!$result )
die('Could not call transaction check1: ' . mysqli_error($con));
$result2=mysqli_query($con,"SELECT @flag");
if(!$result2 )
die('Could not call transaction check2: ' . mysqli_error($con));
$row = mysqli_fetch_assoc($result2);
if($row['@flag']==0)
{
$url = "Bookrequest.php?usrid=".$_SESSION['ID']."&bkrid=".$det['mainid'];
echo '<form method="GET" action="confirm.php">
<input type="hidden" name="link" value="'.$url.'">
<input type="hidden" name="back" value="Booksearch.php">
<input type="hidden" name="bk" value="'.$det['mainid'].'">
<input type="submit" class="but" value="Request Book">
</form>
<br></td>';
}
else if($row['@flag']==1)
echo '<input type="submit" class="but" value="U have this book"></td>';
else if($row['@flag']==2)
{
$url = "Cancelrequest.php?usrid=".$_SESSION['ID']."&bkrid=".$det['mainid'];
echo '<form method="GET" action="confirm.php">
<input type="hidden" name="link" value="'.$url.'">
<input type="hidden" name="back" value="Booksearch.php">
<input type="hidden" name="bk" value="'.$det['mainid'].'">
<input type="submit" class="but" value="Cancel The Request">
</form>
<br></td>';
}
else if($row['@flag']==4)
{
echo '<input type="button" class="but" value="Book Accepted...">
<br></td>';
}
else
echo '<input type="submit" class="but" value="You can\'t request this book..."><br>
(Ur requests is at maximum level or U have already taken 3 books )</td>';
}
echo '</tr></tbody></table><br>';
}
?>
<br>
</td>
</tr>
</tbody>
</table>
<?php ob_end_flush();?>
</body></html>