-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminlgn.php
More file actions
156 lines (148 loc) · 3.98 KB
/
Copy pathadminlgn.php
File metadata and controls
156 lines (148 loc) · 3.98 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
<?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 = "Sucessfully Logged In";
// Check if form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get form data
$username = $_POST['username'];
$password = $_POST['password'];
// Validate input
if (empty($username) || empty($password)) {
die("All fields are required.");
}
// Hash the password
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// Prepare and bind
$stmt = $conn->prepare("INSERT INTO adminlogin(username,password) VALUES (?, ?)");
if ($stmt === false) {
die("Prepare failed: " . htmlspecialchars($conn->error));
}
$stmt->bind_param("ss", $username, $hashed_password,);
// 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;
margin:
}
.nav a{
color:black;
display:inline-block;
text-align:center;
padding: 25px;
padding-left: 310px;
}
.nav a:hover{
text-decoration: underline;
color:blue;
}
form{
width: 600px;
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;
}
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;
}
hr{
margin:0px;
}
</style>
</head>
<body>
<div class="header">
<h1> LIBRARY MANAGEMENT SYSTEM </h1>
</div>
<hr>
<div class="nav">
<a href="Userlogin.php">USER LOGIN
</a>
<a href="usersignup.php">USER SIGNUP
</a>
</div>
<h4 class="adminlgn" style="text-align:center">ADMIN LOGIN FORM</h4>
<form role="form" method="post" action="adminhomepage.php">
<label>Enter Username:</label>
<input class="form-control" type="text" name="username" autocomplete="off" required />
<label>Password:</label>
<input class="form-control" type="password" name="password" autocomplete="off" required />
<button type="submit" name="login" class="btn btn-info">LOGIN </button>
</form>
</body>
</html>