-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathone_time.php
202 lines (181 loc) · 6.53 KB
/
one_time.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
<?php
session_start();
include('./includes/dbcon.php');
// Function to generate the admission number
function generateAdmissionNumber($conn)
{
$result = $conn->query("SELECT COUNT(*) as total FROM tblstudents");
$count = $result->fetch_assoc()['total'];
return 'ADM' . ($count + 1);
}
// Handle form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$otherName = $_POST['otherName'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$dob = $_POST['dob'];
$address = $_POST['address'];
$aadhar_no = $_POST['aadhar_no'];
$parent_name = $_POST['parent_name'];
$parent_phone = $_POST['parent_phone'];
// Check if email or phone number already exists
$checkQuery = "SELECT * FROM tblstudents WHERE std_email = '$email' OR std_phone_number = '$phone'";
$checkResult = $conn->query($checkQuery);
if ($checkResult->num_rows > 0) {
echo "<script>alert('Student already registered with this email or phone number.');</script>";
} else {
// Generate admission number
$admissionNumber = generateAdmissionNumber($conn);
$defaultPassword = md5('12345');
$status = 2; // Default status
// Insert new student into database
$insertQuery = "INSERT INTO tblstudents (std_firstName, std_lastName, std_otherName, std_admissionNumber, std_password, std_dateCreated, std_email, std_phone_number, stud_dob, std_address, std_aadhar_no, std_parent_name, std_parent_ph, std_status)
VALUES ('$firstName', '$lastName', '$otherName', '$admissionNumber', '$defaultPassword', NOW(), '$email', '$phone', '$dob', '$address', '$aadhar_no', '$parent_name', '$parent_phone', '$status')";
if ($conn->query($insertQuery)) {
echo "<script>alert('Registration successful! Your admission number is: $admissionNumber');</script>";
} else {
echo "<script>alert('Error during registration. Please try again.');</script>";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Registration</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" integrity="sha384-k6RqeWeci5ZR/Lv4MR0sA0FfDOMF4zU0EYYWZ1uMEq3fzt5MQuvM1qq5v9Kzq42" crossorigin="anonymous">
<style>
/* Add your custom styles here */
body {
font-family: 'Arial', sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
.container {
max-width: 800px;
margin: 50px auto;
padding: 20px;
background-color: #8A2BE2;
border-radius: 8px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
color: white;
}
h2 {
text-align: center;
margin-bottom: 20px;
color: #fff;
}
.form-group {
margin-bottom: 15px;
}
label {
font-weight: bold;
margin-bottom: 5px;
display: block;
color: #fff;
}
input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
textarea {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
transition: border-color 0.3s;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
textarea:focus {
border-color: #4da6ff;
outline: none;
}
.submit-btn {
background-color: #4da6ff;
color: #fff;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
width: 100%;
font-size: 16px;
transition: background-color 0.3s, transform 0.2s;
}
.submit-btn:hover {
background-color: #007bff;
transform: scale(1.05);
}
.back-link {
text-align: center;
margin-top: 20px;
}
.back-link a {
color: #fff;
text-decoration: none;
}
.back-link a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h2>Student Registration</h2>
<form method="POST" action="">
<div class="form-group">
<label for="firstName">First Name</label>
<input type="text" name="firstName" required>
</div>
<div class="form-group">
<label for="lastName">Last Name</label>
<input type="text" name="lastName" required>
</div>
<div class="form-group">
<label for="otherName">Other Name</label>
<input type="text" name="otherName">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" name="email" required>
</div>
<div class="form-group">
<label for="phone">Phone Number</label>
<input type="text" name="phone" required>
</div>
<div class="form-group">
<label for="dob">Date of Birth</label>
<input type="date" name="dob">
</div>
<div class="form-group">
<label for="address">Address</label>
<textarea name="address" rows="4"></textarea>
</div>
<div class="form-group">
<label for="aadhar_no">Aadhar Number</label>
<input type="number" name="aadhar_no" required>
</div>
<div class="form-group">
<label for="parent_name">Parent Name</label>
<input type="text" name="parent_name" required>
</div>
<div class="form-group">
<label for="parent_phone">Parent Phone Number</label>
<input type="number" name="parent_phone" required>
</div>
<button type="submit" class="submit-btn">Register</button>
</form>
<div class="back-link">
<a href="./index.php"><i class="fas fa-arrow-left"></i> Back to Home</a>
</div>
</div>
</body>
</html>