-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.php
57 lines (46 loc) · 1.7 KB
/
release.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
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
if (count($_POST) > 1)
{
if(!isset($_SESSION))
{
session_start();
}
$con=mysqli_connect("localhost","root","","library");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL DB: " . mysqli_connect_error();
}
array_pop ($_POST);
foreach ($_POST as $key => $value)
{
$sql="DELETE FROM reservedbooks WHERE reservationID = $value";
mysqli_query($con,$sql) or die ("Error in query: $query " . mysql_error());
}
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL DB: " . mysqli_connect_error();
echo '<script type="text/javascript"> alert(\'Database Connection Error\'); </script>';
echo '<script type="text/javascript">location.href = \'viewreserved.php\';</script>';
exit;
}
else
{
echo '<script type="text/javascript"> alert(\'You have sucessfully released a book/books\'); </script>';
echo '<script type="text/javascript">location.href = \'viewreserved.php\';</script>';
}
}
else
{
echo '<script type="text/javascript"> alert(\'You have selected not selected a book to release,please try again\'); </script>';
echo '<script type="text/javascript">location.href = \'viewreserved.php\';</script>';
}
?>
</body>
</html>