-
Notifications
You must be signed in to change notification settings - Fork 0
/
staff_signup.php
245 lines (227 loc) · 7.96 KB
/
staff_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
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<?php
include 'db_connect.php'; // Your database connection file
// Initialize variables and error messages
$firstName = $lastName = $phoneNumber = $email = $skills = $availability = "";
$firstName_err = $lastName_err = $phoneNumber_err = $email_err = $skills_err = $availability_err = "";
// When form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Validate first name
if (empty(trim($_POST["firstName"]))) {
$firstName_err = "Please enter the first name.";
} else {
$firstName = trim($_POST["firstName"]);
}
// Validate last name
if (empty(trim($_POST["lastName"]))) {
$lastName_err = "Please enter the last name.";
} else {
$lastName = trim($_POST["lastName"]);
}
// Validate phone number
if (empty(trim($_POST["phoneNumber"]))) {
$phoneNumber_err = "Please enter the phone number.";
} else {
$phoneNumber = trim($_POST["phoneNumber"]);
}
// Validate email
if (empty(trim($_POST["email"]))) {
$email_err = "Please enter an email.";
} else {
$email = trim($_POST["email"]);
}
// Validate skills
if (empty(trim($_POST["skills"]))) {
$skills_err = "Please enter skills.";
} else {
$skills = trim($_POST["skills"]);
}
// Validate availability
if (empty(trim($_POST["availability"]))) {
$availability_err = "Please enter availability.";
} else {
$availability = trim($_POST["availability"]);
}
// Check input errors before inserting in the database
if (empty($firstName_err) && empty($lastName_err) && empty($phoneNumber_err) && empty($email_err) && empty($skills_err) && empty($availability_err)) {
// Prepare an insert statement
$sql = "INSERT INTO cleaning_staff (FirstName, LastName, PhoneNumber, Email, Skills, Availability) VALUES (?, ?, ?, ?, ?, ?)";
if ($stmt = $conn->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param("ssssss", $param_firstName, $param_lastName, $param_phoneNumber, $param_email, $param_skills, $param_availability);
// Set parameters
$param_firstName = $firstName;
$param_lastName = $lastName;
$param_phoneNumber = $phoneNumber;
$param_email = $email;
$param_skills = $skills;
$param_availability = $availability;
// Attempt to execute the prepared statement
if ($stmt->execute()) {
// Redirect to login page
header("location: login.php");
} else {
echo "Oops! Something went wrong. Please try again later.";
}
// Close statement
$stmt->close();
}
}
// Close connection
$conn->close();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Staff Registration</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
.container {
max-width: 500px;
margin: 50px auto;
padding: 25px;
background: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
h2 {
color: #333;
text-align: center;
margin-bottom: 20px;
}
p {
color: #666;
text-align: center;
margin-bottom: 20px;
}
form {
display: flex;
flex-direction: column;
gap: 15px;
}
.form-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: bold;
}
input[type="text"],
input[type="email"],
input[type="password"] {
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
display: block;
width: 100%;
box-sizing: border-box; /* Adds padding without increasing the width */
}
input[type="submit"] {
padding: 12px;
background-color: #5cb85c;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.2s;
font-size: 16px;
font-weight: bold;
margin-top: 10px;
}
input[type="submit"]:hover {
background-color: #4cae4c;
}
.form-group span {
color: #d9534f;
font-size: 14px;
}
a {
text-decoration: none;
color: #5cb85c;
}
a:hover {
text-decoration: underline;
}
a.register-link {
display: block;
text-align: center;
margin-top: 15px;
font-weight: bold;
color: #337ab7;
}
.back-to-home {
display: inline-block;
padding: 10px 7px;
text-decoration: none;
background-color: #007bff;
color: white;
border-radius: 4px;
font-size: 16px;
transition: background-color 0.3s ease;
margin-left: 30px;
font-weight: bold;
}
.back-to-home:hover {
background-color: #0056b3;
text-decoration: none;
color: white;
}
/* Additional styling for focus on the button */
.back-to-home:focus {
outline: none;
box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.5);
}
</style>
</head>
<body>
<div class="container">
<h2>Staff Registration</h2>
<p>Please fill in this form to create a staff account.</p>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="form-group">
<label>First Name</label>
<input type="text" name="firstName" value="<?php echo $firstName; ?>">
<span><?php echo $firstName_err; ?></span>
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" name="lastName" value="<?php echo $lastName; ?>">
<span><?php echo $lastName_err; ?></span>
</div>
<div class="form-group">
<label>Phone Number</label>
<input type="text" name="phoneNumber" value="<?php echo $phoneNumber; ?>">
<span><?php echo $phoneNumber_err; ?></span>
</div>
<div class="form-group">
<label>Email</label>
<input type="email" name="email" value="<?php echo $email; ?>">
<span><?php echo $email_err; ?></span>
</div>
<div class="form-group">
<label>Skills</label>
<input type="text" name="skills" value="<?php echo $skills; ?>">
<span><?php echo $skills_err; ?></span>
</div>
<div class="form-group">
<label>Availability</label>
<input type="text" name="availability" value="<?php echo $availability; ?>">
<span><?php echo $availability_err; ?></span>
</div>
<div class="form-group">
<input type="submit" value="Register"> <a href="welcome.php" class="back-to-home">Back to Home</a>
</div>
</form>
<!-- <p>Already have an account? <a href="login.php">Login here</a>.</p>
<p>Are you a customer? <a href="signup.php">Register here</a>.</p> -->
</div>
</body>
</html>