-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathburrow.php
33 lines (29 loc) · 889 Bytes
/
burrow.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
<?php
$id=$_GET['id'];
$email=$_GET['email'];
$retdate=$_GET['retdate'];
//$d="afsdfdsf";
$servername = "172.17.0.2";
$username = "admn";
$password = "Asdf@1234";
$dbname = "library";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$today=date("Y-m-d");
$sql = "INSERT INTO burrowbook (bookId , email, burrowDate, returnDate ,returnStatus) VALUES ('{$id}', '{$email}','{$today}','{$retdate}','n')";
$sql2 = "UPDATE books set availability = 'n' where bookID = '{$id}'";
if ($conn->query($sql) === TRUE and $conn->query($sql2) == TRUE) {
echo "Book Borrowed";
} else {
if( $conn->errno === 1062){
echo "<h1 style='color:red;'>Book not available<br> used";
}else{
echo "Error: " . $sql . "<br>" . $conn->errno;
}
}
$conn->close();
?>