-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_user.php
More file actions
351 lines (317 loc) · 13.6 KB
/
add_user.php
File metadata and controls
351 lines (317 loc) · 13.6 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
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>::: Add User :::</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, sans-serif;
background: url("add_usr.png");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
color: #fff;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100%;
min-height: 100vh; /* Ensure the body takes the full height */
overflow-y: auto; /* Make page scrollable if content overflows */
}
/* Center aligned container for Add User */
.container {
width: 60%; /* Adjust width of the container */
background-color: rgba(255, 255, 255, 0.8); /* White semi-transparent background */
padding: 20px;
border-radius: 8px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
color: black; /* Black text color */
overflow-y: auto; /* Ensure the container is scrollable */
}
h2 {
text-align: center; /* Center-align the 'Add User' heading */
margin-bottom: 20px;
color: #333;
}
/* Style for the tab links */
.tab {
overflow: hidden;
border-bottom: 1px solid #ccc;
text-align: center;
margin-bottom: 20px;
}
.tab button {
background-color: #f1f1f1;
border: none;
padding: 12px 24px;
cursor: pointer;
font-size: 18px;
color: #333;
margin: 0 5px;
border-radius: 8px;
transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
/* Glow effect on hover */
.tab button:hover {
background-color: #add8e6;
box-shadow: 0 0 10px #add8e6;
}
/* Active tab button styling */
.tab button.active {
background-color: #add8e6;
color: #fff;
box-shadow: 0 0 10px #add8e6;
}
/* Style for the tab content */
.tabcontent {
display: none;
padding: 20px;
border-top: none;
background-color: rgba(255, 255, 255, 0.9);
border-radius: 10px;
margin-top: 20px;
}
/* Style for the form inputs */
input[type="text"], input[type="number"]{
width: 100%;
padding: 10px;
margin: 10px 0;
border-radius: 5px;
border: 1px solid #ccc;
font-size: 16px;
}
/* Narrower submit button */
input[type="submit"] {
cursor: pointer;
padding: 12px 24px; /* Added padding to make the button larger */
border-radius: 12px; /* Rounded corners */
border: 0;
text-shadow: 1px 1px #000a;
background: linear-gradient(#006caa, #00c3ff);
box-shadow: 0px 4px 6px 0px #0008;
font-weight: 550;
color: white;
font-size: 16px;
outline: none; /* Remove the default outline */
transition: box-shadow 0.3s ease; /* Smooth transition for glow effect */
}
input[type="submit"]:hover {
box-shadow: 0px 6px 12px 0px #0009, /* Standard shadow */
0 0 12px 4px #00c3ff; /* Glow effect */
}
input[type="submit"]:active {
box-shadow: 0px 0px 0px 0px #0000; /* Remove shadow on active */
}
/* Add some margin to the form */
form {
padding: 20px;
}
</style>
</head>
<body>
<?php
// Database connection
$servername = "localhost";
$username = "root"; // Default username for XAMPP
$password = ""; // Default password for XAMPP
$dbname = "erp";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Function to insert data into tables
function insertData($table, $data) {
global $conn;
$columns = implode(", ", array_keys($data));
$values = implode("', '", array_values($data));
$sql = "INSERT INTO $table ($columns) VALUES ('$values')";
if ($conn->query($sql) === TRUE) {
echo "<script>alert('Data submitted successfully!');</script>";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
// Handle form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$formType = $_POST['form_type'];
$loginData = [
'Uname' => $_POST['username'],
'pwd' => $_POST['password'],
'fname' => $_POST['login_fname'],
'lname' => $_POST['login_lname'],
'status' => $_POST['status']
];
// Insert into login_details table
insertData('login_details', $loginData);
switch ($formType) {
case 'student':
$studentData = [
'fname' => $_POST['student_fname'],
'lname' => $_POST['student_lname'],
'phone' => $_POST['student_phone'],
'address' => $_POST['student_address'],
'class' => $_POST['student_class'],
'gender' => $_POST['student_gender'],
'blood_group' => $_POST['student_blood_group']
];
insertData('student_details', $studentData);
break;
case 'parent':
$parentData = [
'fname' => $_POST['parent_fname'],
'lname' => $_POST['parent_lname'],
'stud_fname' => $_POST['student_fname'],
'stud_lname' => $_POST['student_lname'],
'phone' => $_POST['parent_phone'],
'gender' => $_POST['parent_gender']
];
insertData('parent_details', $parentData);
break;
case 'teacher':
$teacherData = [
'fname' => $_POST['teacher_fname'],
'lname' => $_POST['teacher_lname'],
'address' => $_POST['teacher_address'],
'phone' => $_POST['teacher_phone'],
'subject' => $_POST['teacher_subject'],
'gender' => $_POST['teacher_gender'],
'blood_group' => $_POST['teacher_blood_group'],
'class' => $_POST['teacher_class']
];
insertData('teacher_details', $teacherData);
break;
case 'admin':
$adminData = [
'fname' => $_POST['admin_fname'],
'lname' => $_POST['admin_lname'],
'address' => $_POST['admin_address'],
'phone' => $_POST['admin_phone'],
'gender' => $_POST['admin_gender'],
'blood_group' => $_POST['admin_blood_group']
];
insertData('admin_details', $adminData);
break;
}
}
?>
<div class="container">
<h2>Add User</h2>
<div class="tab">
<button class="tablinks" onclick="openTab(event, 'Tab1')">Add Student</button>
<button class="tablinks" onclick="openTab(event, 'Tab2')">Add Parent</button>
<button class="tablinks" onclick="openTab(event, 'Tab3')">Add Teacher</button>
<button class="tablinks" onclick="openTab(event, 'Tab4')">Add Admin</button>
</div>
<!-- Add Student -->
<div id="Tab1" class="tabcontent">
<h3>Add Student Details</h3>
<form method="post">
<input type="hidden" name="form_type" value="student">
<p><b>Login Details</b></p>
Username: <input type="text" name="username"><br>
Password: <input type="text" name="password"><br>
First Name: <input type="text" name="login_fname"><br>
Last Name: <input type="text" name="login_lname"><br>
Status: <input type="text" name="status" value="Student" readonly><br>
<p><b>Student Details</b></p>
First Name: <input type="text" name="student_fname"><br>
Last Name: <input type="text" name="student_lname"><br>
Phone: <input type="text" name="student_phone"><br>
Address: <input type="text" name="student_address"><br>
Class: <input type="number" name="student_class"><br>
Gender: <input type="text" name="student_gender"><br>
Blood Group: <input type="text" name="student_blood_group"><br>
<input type="submit" value="Submit" style="display: block; margin: 0 auto; padding: 12px 24px; border-radius: 12px; border: 0; background: linear-gradient(#006caa, #00c3ff); color: white; font-weight: 550; font-size: 16px; cursor: pointer;">
</form>
</div>
<!-- Add Parent -->
<div id="Tab2" class="tabcontent">
<h3>Add Parent Details</h3>
<form method="post">
<input type="hidden" name="form_type" value="parent">
<p><b>Login Details</b></p>
Username: <input type="text" name="username"><br>
Password: <input type="text" name="password"><br>
First Name: <input type="text" name="login_fname"><br>
Last Name: <input type="text" name="login_lname"><br>
Status: <input type="text" name="status" value="Parent" readonly><br>
<p><b>Parent Details</b></p>
First Name: <input type="text" name="parent_fname"><br>
Last Name: <input type="text" name="parent_lname"><br>
Student First Name: <input type="text" name="student_fname"><br>
Student Last Name: <input type="text" name="student_lname"><br>
Phone: <input type="text" name="parent_phone"><br>
Gender: <input type="text" name="parent_gender"><br>
<input type="submit" value="Submit" style="display: block; margin: 0 auto; padding: 12px 24px; border-radius: 12px; border: 0; background: linear-gradient(#006caa, #00c3ff); color: white; font-weight: 550; font-size: 16px; cursor: pointer;">
</form>
</div>
<!-- Add Teacher -->
<div id="Tab3" class="tabcontent">
<h3>Add Teacher Details</h3>
<form method="post">
<input type="hidden" name="form_type" value="teacher">
<p><b>Login Details</b></p>
Username: <input type="text" name="username"><br>
Password: <input type="text" name="password"><br>
First Name: <input type="text" name="login_fname"><br>
Last Name: <input type="text" name="login_lname"><br>
Status: <input type="text" name="status" value="Teacher" readonly><br>
<p><b>Teacher Details</b></p>
First Name: <input type="text" name="teacher_fname"><br>
Last Name: <input type="text" name="teacher_lname"><br>
Address: <input type="text" name="teacher_address"><br>
Phone: <input type="text" name="teacher_phone"><br>
Subject: <input type="text" name="teacher_subject"><br>
Gender: <input type="text" name="teacher_gender"><br>
Blood Group: <input type="text" name="teacher_blood_group"><br>
Class: <input type="number" name="teacher_class"><br>
<input type="submit" value="Submit" style="display: block; margin: 0 auto; padding: 12px 24px; border-radius: 12px; border: 0; background: linear-gradient(#006caa, #00c3ff); color: white; font-weight: 550; font-size: 16px; cursor: pointer;">
</form>
</div>
<!-- Add Admin -->
<div id="Tab4" class="tabcontent">
<h3>Add Admin Details</h3>
<form method="post">
<input type="hidden" name="form_type" value="admin">
<p><b>Login Details</b></p>
Username: <input type="text" name="username"><br>
Password: <input type="text" name="password"><br>
First Name: <input type="text" name="login_fname"><br>
Last Name: <input type="text" name="login_lname"><br>
Status: <input type="text" name="status" value="Admin" readonly><br>
<p><b>Admin Details</b></p>
First Name: <input type="text" name="admin_fname"><br>
Last Name: <input type="text" name="admin_lname"><br>
Phone: <input type="text" name="admin_phone"><br>
Gender: <input type="text" name="admin_gender"><br>
Blood Group: <input type="text" name="admin_blood_group"><br>
<input type="submit" value="Submit" style="display: block; margin: 0 auto; padding: 12px 24px; border-radius: 12px; border: 0; background: linear-gradient(#006caa, #00c3ff); color: white; font-weight: 550; font-size: 16px; cursor: pointer;">
</form>
</div>
</div>
<script>
function openTab(evt, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}
// Set default active tab
document.getElementsByClassName("tablinks")[0].click();
</script>
</body>
</html>
<?php $conn->close(); ?>