-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemand_book.php
More file actions
102 lines (87 loc) · 3.07 KB
/
demand_book.php
File metadata and controls
102 lines (87 loc) · 3.07 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
<?php
require("first.php");
include("db.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<title>Document</title>
<style>
.content {
max-width: 1130px;
margin-left: 300px;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
margin-top: 20px;
}
</style>
</head>
<body>
<div class="content">
<div class="demand-book-form">
<div class="d-flex justify-content-between align-items-center mb-4">
<h3>Demand Book</h3>
<form action="show_demands.php" method="post">
<a href="show_demands.php"><button type="submit" class="btn btn-primary mr-2" name="show_demand_books">Show Demand Books</button></a>
</form>
</div>
<form action="demand_book.php" method="post">
<div class="form-group">
<label for="student_id">Student ID:</label>
<input type="text" class="form-control" id="student_id" name="student_id" required>
</div>
<div class="form-group">
<label for="book_title">Book Title:</label>
<input type="text" class="form-control" id="book_title" name="book_title" required>
</div>
<div class="form-group">
<label for="author">Author:</label>
<input type="text" class="form-control" id="author" name="author" required>
</div>
<div class="form-group">
<label for="publisher">Publisher:</label>
<input type="text" class="form-control" id="publisher" name="publisher" required>
</div>
<div class="form-group">
<label for="demand_date">Demand Date:</label>
<input type="date" class="form-control" id="demand_date" name="demand_date">
</div>
<button type="submit" class="btn btn-primary" name="demand_book">Demand Book</button>
</form>
<!-- JavaScript to disable past dates in issued_date input -->
<script>
// Get the current date
var today = new Date().toISOString().split('T')[0];
// Set the min attribute of the issued_date input to today's date
document.getElementById("demand_date").setAttribute("min", today);
</script>
</div>
<?php
if (isset($_POST['demand_book']))
{
$student_id = $_POST['student_id'];
$book_title = $_POST['book_title'];
$author = $_POST['author'];
$publisher = $_POST['publisher'];
$demand_date = $_POST['demand_date'];
$insert_query = "INSERT INTO book_demand (student_id,book_title,author,publisher,demand_date)
VALUES('$student_id','$book_title','$author','$publisher','$demand_date')";
$result = mysqli_query($connect, $insert_query);
if ($result)
{
echo "Demand Added Successfully";
}
else
{
echo "Error:" . $result . "<br>";
}
}
?>
</div>
</body>
</html>