-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreturnBook.php
94 lines (68 loc) · 2.38 KB
/
returnBook.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
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
<!DOCTYPE html>
<html>
<head>
<title>Return Book</title>
<link rel="stylesheet" href="returnBook_style.css" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<form action="returnBook.php" method="POST">
<div class="icon-bar">
<a href="parallax.php"><i class="fa fa-home" title="Home"></i></a>
<a href="studentRegister.php"><i class="fa fa-user-o" title="Student Registration"></i></a>
<a href="findBook.php"><i class="fa fa-search" title="Search Book"></i></a>
<a class="active" href="BorrowBook.php"><i class="fa fa-sign-out" title="Issue Book"></i></a>
<a href="returnBook.php"><i class="fa fa-sign-in" title="Return Book"></i></a>
<a href="addBook.php"><i class="fa fa-plus" title="Add Book"></i></a>
</div>
<div class="detailsDiv" align="center">
<h1 align="center" id="heading">Return Book</h1>
<label id="b">Roll No</label> <input type="number" id="r" name="rollNum" required="required" maxlength="11"> <br>
<label id="b">Name</label> <input type="text" id="d" name="name" required="required" maxlength="13"> <br>
<button type="submit" name="returnBtn" class="submit"><span>RETURN</span></button>
</div>
<?php
$dbhost="localhost";
$username="root";
$password="";
$db="library";
$RollNo="";
$Name="";
$IssueDate="";
$ReturnDate="";
$con=mysqli_connect("$dbhost","$username","$password");
mysqli_select_db($con,$db);
function getPosts()
{
$posts=array();
$posts[0]=$_POST['rollNum'];
$posts[1]=$_POST['name'];
return $posts;
}
if(isset($_POST['returnBtn'])){
$data=getPosts();
$return_query="DELETE FROM `infobook` WHERE Roll_No='$data[0]' AND Name='$data[1]';";
$return_result=mysqli_query($con, $return_query);
if($return_result)
{
if(mysqli_affected_rows($con)>0)
{
echo '<script language="javascript">';
echo 'alert("Book RETURNED")';
echo '</script>';
}else{
echo '<script language="javascript">';
echo 'alert("ERROR: Enter Valid Details.")';
echo '</script>';
}
}else{
echo '<script language="javascript">';
echo 'alert("RESULT ERROR.")';
echo '</script>';
}
}
?>
</form>
</body>
</html>