-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
144 lines (143 loc) · 5.05 KB
/
signup.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
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
<?php
session_start();
include('db.php');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = $_POST['username'];
$email = $_POST['email'];
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
$role = $_POST['role'];
$sql = "INSERT INTO users (username, email, password, role) VALUES ('$username', '$email', '$password', '$role')";
if ($conn->query($sql) === TRUE) {
if ($role == 'admin') {
header('Location: admin_login.php');
} else {
header('Location: login.php');
}
exit();
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Signup</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
<style>
body {
background-image: url("INVENTORY.webp");
background-size: cover;
background-position: center;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
font-family: 'Arial', sans-serif;
color: #333;
}
.container {
background-color: rgba(255, 255, 255, 0.9);
padding: 40px;
border-radius: 15px;
box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease;
}
.container:hover {
transform: translateY(-10px);
}
h1 {
margin-bottom: 30px;
font-size: 2.5rem;
font-weight: bold;
color: #007BFF;
}
.input-group-text {
background-color: #007BFF;
color: white;
}
.btn-primary {
background-color: #007BFF;
border-color: #007BFF;
}
.btn-primary:hover {
background-color: #0056b3;
border-color: #0056b3;
}
.btn-link {
color: #007BFF;
}
.btn-link:hover {
text-decoration: underline;
}
#loader {
display: none;
}
@media (max-width: 768px) {
.container {
padding: 20px;
}
h1 {
font-size: 2rem;
}
}
</style>
</head>
<body>
<div class="container animate__animated animate__fadeInDown mt-5">
<h1>Signup</h1>
<form method="POST" action="" onsubmit="showLoader()">
<div class="mb-4">
<label for="username" class="form-label">Username</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-user"></i></span>
<input type="text" class="form-control" id="username" name="username" required>
</div>
</div>
<div class="mb-4">
<label for="email" class="form-label">Email</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-envelope"></i></span>
<input type="email" class="form-control" id="email" name="email" required>
</div>
</div>
<div class="mb-4">
<label for="password" class="form-label">Password</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-lock"></i></span>
<input type="password" class="form-control" id="password" name="password" required>
</div>
</div>
<div class="mb-4">
<label for="role" class="form-label">Role</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-user-tag"></i></span>
<select class="form-control" id="role" name="role" required>
<option value="admin">Admin</option>
<option value="user">User</option>
</select>
</div>
</div>
<button type="submit" class="btn btn-primary w-100">Signup</button>
<a href="login.php" class="btn btn-link d-block text-center mt-2">Already have an account? Login here.</a>
</form>
<!-- Loader -->
<div id="loader" class="text-center mt-3">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<p>Please wait...</p>
</div>
</div>
<script>
function showLoader() {
document.querySelector('button[type="submit"]').disabled = true;
document.getElementById('loader').style.display = 'block';
}
</script>
</body>
</html>