-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusersignup.php
More file actions
176 lines (166 loc) · 5 KB
/
Copy pathusersignup.php
File metadata and controls
176 lines (166 loc) · 5 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
<?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
$fullname = $_POST['fullname'];
$mobilenumber=$_POST['mobilenumber'];
$email = $_POST['email'];
$password = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
// Validate input
if (empty($fullname) || empty($mobilenumber) || empty($email) || empty($password) || empty($confirmpassword)) {
die("All fields are required.");
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
die("Invalid email format.");
}
if ($password !== $confirmpassword) {
die("Passwords do not match.");
}
// Prepare and bind
$stmt = $conn->prepare("INSERT INTO usersignup (fullname, mobilenumber, email, password, confirmpassword) VALUES (?, ?, ?, ?, ?)");
if ($stmt === false) {
die("Prepare failed: " . htmlspecialchars($conn->error));
}
$stmt->bind_param("sssss", $fullname, $mobilenumber, $email, $password,$password);
// Execute the statement
if ($stmt->execute()) {
header("Location: userhomepage.php");
exit();
} 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;
}
hr{
margin:0px;
}
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;
}
</style>
</head>
<body>
<div class="header">
<h1> LIBRARY MANAGEMENT SYSTEM </h1>
</div>
<hr>
<div class="nav">
<a href="adminlgn.php">ADMIN LOGIN
</a>
<a href="Userlogin.php">USER LOGIN
</a>
</div>
<h4 class="usersignup" style="text-align:center">USER SIGNUP FORM</h4>
<?php if ($message): ?>
<p style="color:Blue; text-align:center;"><?php echo $message; ?></p>
<?php endif; ?>
<form action="usersignup.php" name="usersignup" method="post" >
<label>Enter Full Name</label>
<input class="form-control" type="text" name="fullname" autocomplete="off" required />
<label>Mobile Number :</label>
<input class="form-control" type="text" name="mobilenumber" maxlength="10" autocomplete="off" required />
<label>Enter Email</label>
<input class="form-control" type="email" name="email" id="emailid" onBlur="checkAvailability()" autocomplete="off" required />
<span id="user-availability-status" style="font-size:12px;"></span>
<label>Enter Password</label>
<input class="form-control" type="password" name="password" autocomplete="off" required />
<label>Confirm Password </label>
<input class="form-control" type="password" name="confirmpassword" autocomplete="off" required />
<button type="submit" name="signup" class="btn btn-danger" id="submit">Register Now </button>
</form>
</body>
</html>