-
Notifications
You must be signed in to change notification settings - Fork 0
/
BorrowBook.php
115 lines (90 loc) · 3.17 KB
/
BorrowBook.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE html>
<html>
<head>
<title>Borrow Book</title>
<link rel="stylesheet" href="BorrowBook_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="BorrowBook.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">Borrow Book</h1>
<label id="b">Roll No</label> <input type="number" id="r" name="rollNum" required="required" maxlength="11"> <br>
<label id="b">Book Name</label> <input type="text" id="d" name="name" required="required" maxlength="50"><br>
<label id="b">Issue Date</label><input type="text" id="a" name="issueDate" required><br>
<label id="b">Return Data</label> <input type="text" id="f" name="returnDate" required ><br><br>
<button type="submit" name="issueBtn" class="submit" ><span>BORROW</span></button>
</div>
<?php
$dbhost="localhost";
$username="root";
$password="";
$db="library";
$RollNo="";
$Name="";
$Author="";
$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'];
$posts[2]=$_POST['issueDate'];
$posts[3]=$_POST['returnDate'];
return $posts;
}
if(isset($_POST['issueBtn'])){
$data=getPosts();
$getBookData_query="SELECT `Name`, `Category`, `Author`, `Edition` FROM `book` WHERE Name=$data[0] ;";
$getBookData_result=mysqli_query($con,$getBookData_query);
if($getBookData_result){
if(mysqli_num_rows($getBookData_result))
{
while($row=mysqli_fetch_array($getBookData_result))
{
$Name=$row['Name'];
$Category=$row['Category'];
$Author=$row['Author'];
$Editon=$row['Edition'];
}
}else{
echo '<script language="javascript">';
echo 'alert(" ERROR:---->Enter Valid Details.")' ;
echo '</script>';
die;
}
}else{
echo "Result Error 1.";
}
$issue_query="INSERT INTO `infobook`(`Roll_No`, `Name`, `issueDate`, `returnDate`) VALUES ('$data[0]','$data[1]','$data[2]','$data[3]');";
$issue_result=mysqli_query($con, $issue_query);
if($issue_result)
{
if(mysqli_affected_rows($con)>0)
{
echo '<script language="javascript">';
echo 'alert("Book ISSUED")';
echo '</script>';
}else{
echo "No data inserted.";
}
}else{
echo "Result Error 2.";
}
}
?>
</form>
</body>
</html>