-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturnfinal.php
More file actions
241 lines (172 loc) · 6.44 KB
/
returnfinal.php
File metadata and controls
241 lines (172 loc) · 6.44 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
<?php
session_start();
if(isset($_GET['name1'])) {
$username= $_GET['name1'];
}
if(isset($_GET['updatedbookscanissuemore'])) {
$updatedbookscanissuemore= $_GET['updatedbookscanissuemore'];
}
//include("db_connect.php");
$conn = oci_connect('cse_15101028','15101028','172.16.61.126/dbtest');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$isbnno= $_POST['isbn_'];
$quantityno= $_POST['quantity_'];
$availableno= $_POST['available_'];
//$query='insert into borrowed(username,isbn_no,issue_date,due_date) values(\''.$username.'\',\''.$isbnno.'\',sysdate,sysdate+14)';
$query='update borrowed set A_returndate=sysdate where username=\''.$username.'\'and A_returndate is null and isbn_no='.$isbnno.'';
echo $query;
$stid = oci_parse($conn, $query);
$result=oci_execute($stid);
echo($result);
$query='update books set available=available+1 where isbn_no=\''.$isbnno.'\'';
//$query1=select round( days_between( sysdate,)) as monthsleft from borrowed;
$query1='select round(sysdate-(select due_date from borrowed where isbn_NO=\''.$isbnno.'\' and username=\''.$username.'\')) from borrowed';
echo $query;
$stid = oci_parse($conn, $query);
$result=oci_execute($stid);
$stid1 = oci_parse($conn, $query1);
$result=oci_execute($stid1);
echo($result);
echo "books updated";
$updatedbookscanissuemore=$updatedbookscanissuemore-1;
echo $updatedbookscanissuemore;
echo "your book has been returned";
if(($row = oci_fetch_row($stid1)) != false){
$fine = $row[0];
echo $fine;
if($fine<=0){
$fine=0;
$query2='update borrowed set fine='.$fine.' where isbn_no=\''.$isbnno.'\' and username=\''.$username.'\'';
$stid3 = oci_parse($conn, $query2);
$result=oci_execute($stid3);
header("Location:returnbookscheck.php?error=4&user=$username&booksisuedyet=$updatedbookscanissuemore");
}
if($fine>0){
$query2='update borrowed set fine='.$fine.' where isbn_no=\''.$isbnno.'\' and username=\''.$username.'\'';
$stid3 = oci_parse($conn, $query2);
$result=oci_execute($stid3);
header("Location:returnbookscheck.php?error=4&user=$username&booksisuedyet=$updatedbookscanissuemore");
}
}
//header("Location:returnbookscheck.php?error=4&user=$username&booksisuedyet=$updatedbookscanissuemore");
/*if(($row = oci_fetch_row($stid)) != false){
$booksissuedtilldate = $row[0];
echo $booksissuedtilldate;
if($booksissuedtilldate<=4){
header("Location:issuebooks.php?booksisuedyet=$row[0]$&user=$Username");
}
else {
header("location:issuebooks.php?error=1&booksisuedyet=$row[0]");
}
//header("Location:indexuser.php?name=$row[2]");
//echo "Welcome, ".$_SESSION['Username']."!<br><a href='logout.php'>LOGOUT</a>";
}
else {
echo "Invalid Userinformation";
header("location:issuebooks.php?error=1&booksisuedyet=$row[0]");
}
if($Category=="staff"){
$query='SELECT count(*) FROM borrowed WHERE username = \''.$Username.'\'';
echo $query;
$stid = oci_parse($conn, $query);
$result=oci_execute($stid);
echo($result);
if(($row = oci_fetch_row($stid)) != false){
$booksissuedtilldate = $row[0];
echo $booksissuedtilldate;
if($booksissuedtilldate<4){
header("Location:issuebooks.php?booksisuedyet=$row[0]&user=$Username");
}
else {
header("location:indexstaff.php?error=2&booksisuedyet=$row[0]");
}
//header("Location:indexuser.php?name=$row[2]");
//echo "Welcome, ".$_SESSION['Username']."!<br><a href='logout.php'>LOGOUT</a>";
}
else {
echo "Invalid User information";
//header("location:issuebooks.php?error=1 booksisuedyet=$row[0]");
}
}
// If result matched $myusername and $mypassword, table row must be 1 row
/* if(($row = oci_fetch_row($stid)) != false){
$username = $row[0];
$name=$row[2];
// echo $row[0];
//echo $row[1];
//echo $row[2];
//echo $row[3];
//echo "<a href='member.php'>Click</a> here to enter";
$_SESSION['Username'] = $username;
if($_SESSION['Username']){
header("Location:indexuser.php?name=$row[2]");
//echo "Welcome, ".$_SESSION['Username']."!<br><a href='logout.php'>LOGOUT</a>";
}
oci_close($conn);
}
else {
//echo "Wrong Username or Password";
header("location:index.php?error=1");
//echo "<font color= "red"><p align="center">Snap! Username or Password donot match.</p></font>";
}
}
else if($Category=="staff"){
$query='SELECT * FROM staffdb WHERE user_name = \''.$Username.'\' and password = \''.$Password.'\'';
echo $query;
$stid = oci_parse($conn, $query);
$result=oci_execute($stid);
echo($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if(($row = oci_fetch_row($stid)) != false){
$username = $row[0];
$name=$row[2];
// echo $row[0];
//echo $row[1];
//echo $row[2];
//echo $row[3];
//echo "<a href='member.php'>Click</a> here to enter";
$_SESSION['Username'] = $username;
if($_SESSION['Username']){
header("Location:indexstaff.php?name=$row[2]");
//echo "Welcome, ".$_SESSION['Username']."!<br><a href='logout.php'>LOGOUT</a>";
}
oci_close($conn);
}
else {
//echo "Wrong Username or Password";
header("location:index.php?error=1");
//echo "<font color= "red"><p align="center">Snap! Username or Password donot match.</p></font>";
}
}
else{
$query='SELECT * FROM admindb WHERE user_name = \''.$Username.'\' and password = \''.$Password.'\'';
echo $query;
$stid = oci_parse($conn, $query);
$result=oci_execute($stid);
echo($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if(($row = oci_fetch_row($stid)) != false){
$username = $row[0];
$name=$row[2];
// echo $row[0];
//echo $row[1];
//echo $row[2];
//echo $row[3];
//echo "<a href='member.php'>Click</a> here to enter";
$_SESSION['Username'] = $username;
if($_SESSION['Username']){
header("Location:indexadmin.php?name=$row[2]");
//echo "Welcome, ".$_SESSION['Username']."!<br><a href='logout.php'>LOGOUT</a>";
}
oci_close($conn);
}
else {
//echo "Wrong Username or Password";
header("location:index.php?error=1");
//echo "<font color= "red"><p align="center">Snap! Username or Password donot match.</p></font>";
}
}*/
?>