-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthors.php
More file actions
181 lines (178 loc) · 5.07 KB
/
Copy pathauthors.php
File metadata and controls
181 lines (178 loc) · 5.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
session_start();
// Database configuration
$servername = "localhost:3307";
$username = "root";
$password = "venessa33";
$dbname = "librarymain";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Variable to store any message to be displayed
$message = "";
// Check if form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get form data
$AuthorID = $_POST['AuthorID'];
$AuthorName=$_POST['AuthorName'];
$AuthorEmail = $_POST['AuthorEmail'];
$Noofbooks=$_POST['Noofbooks'];
// Validate input
if (empty($AuthorID) || empty($AuthorName) || empty($AuthorEmail) || empty($Noofbooks) ) {
die("All fields are required.");
}
// Prepare and bind
$stmt = $conn->prepare("INSERT INTO authors(AuthorID,AuthorName,AuthorEmail,Noofbooks) VALUES (?,?,?,?)");
if ($stmt === false) {
die("Prepare failed: " . htmlspecialchars($conn->error));
}
$stmt->bind_param("ssss",$AuthorID,$AuthorName,$AuthorEmail,$Noofbooks);
// Execute the statement
if ($stmt->execute()) {
echo "New record created successfully";
} else {
echo "Error: " . htmlspecialchars($stmt->error);
}
// Close the statement
$stmt->close();
// Close the connection
$conn->close();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body{
align-items: center;
justify-content: center;
font-family: sans-serif;
background: #f3f3f3;
flex-direction: column;
margin: 0;
}
.header{
text-transform: uppercase;
font-family: 'Times New Roman', Times, serif;
text-align: center;
color:black;
font-style:italic;
background-color:lightblue;
margin-top:-45px;
height:80px;
padding-top:30px
}
.nav{
background-color:lightblue;
}
.nav a{
text-decoration: none;
color:black;
padding: 30px 35px;
display:inline-block;
text-align:center;
}
.nav a:hover{
text-decoration: underline;
color:blue;
}
hr{
margin:0px;
}
form{
max-width:100%;
display: block;
margin: auto;
border-radius: 15px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
padding: 5px 10px;
transition: transform 0.2s;
}
label {
display: block;
width: 100%;
margin-top:3px;
margin-bottom:3px;
text-align: left;
color: #555;
font-weight: bold;
}
input {
display: block;
width: 100%;
margin-bottom:5px;
padding: 10px;
box-sizing: border-box;
border: 2px solid #ddd;
border-radius: 5px;
}
.nav button{
background-color:brown;
border: none;
color:white;
text-align: center;
font-size:16px;
border-radius:20px;
padding:10px;
}
.nav button:hover{
background-color:blueviolet;
}
select{
display: block;
width: 100%;
margin-top:3px;
margin-bottom:3px;
text-align: left;
color: #555;
font-weight: bold;
height:30px;
}
button{
padding: 15px;
border-radius: 10px;
margin-top: 15px;
margin-bottom: 15px;
border: none;
color: white;
cursor: pointer;
background-color:rgb(123, 56, 211);
width: 100%;
font-size: 16px;
}
</style>
</head>
<body>
<div class="header">
<h1> LIBRARY MANAGEMENT SYSTEM </h1>
</div>
<hr>
<div class="nav">
<a href="adminhomepage.php">DASHBOARD</a>
<a href="categories.php">CATEGORIES </a>
<a href="authors.php">AUTHORS</a>
<a href="books.php">BOOKS</a>
<a href="issuebooks.php">ISSUE BOOKS</a>
<a href="regusers.php">REG USERS</a>
<a href="">
<button>Log Out</button>
</a>
</div>
<h4 class="regusers" style="text-align:center">AUTHORS</h4>
<form role="form" method="post" action="authors.php">
<label>Author ID:</label>
<input class="form-control" type="id" name="AuthorID" autocomplete="off" required />
<label>Author Name:</label>
<input class="form-control" type="text" name="AuthorName" required autocomplete="off" />
<label>Author Email:</label>
<input class="form-control" type="text" name="AuthorEmail" required autocomplete="off" />
<label>Number Of Books:</label>
<input class="form-control" type="number" name="Noofbooks" required autocomplete="off" />
<button type="submit" name="login" class="btn btn-info" onclick="alert('Your Authors Have Been Updated')">SUBMIT </button>
</form>
</body>
</html>