forked from hung1605/student_manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_student.php
73 lines (62 loc) · 2.14 KB
/
add_student.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
<?php
session_start();
if (!isset($_SESSION['loggedin'])) {
header("Location: login.php");
exit();
}
include 'functions/class_functions.php';
include 'templates/header.php';
include 'functions/student_functions.php';
// Retrieve the list of classes from the database
$classes = getAllClasses();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$class = $_POST['class'];
$dob = $_POST['dob'];
$address = $_POST['address'];
$gender = $_POST['gender'];
if (addStudent($name, $class, $dob, $address, $gender)) {
echo "Student added successfully.";
header("Location: students_manager.php");
exit();
} else {
echo "Error adding student.";
}
}
?>
<div class="container w-50 border rounded shadow-sm p-3 mb-5 bg-white rounded text-dark">
<h2 class="text-dark ">Add Student</h2>
<form method="post">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" name="name" class="form-control" required>
</div>
<div class="form-group">
<label for="class">Class:</label>
<select id="class" name="class" class="form-control" required>
<?php while ($row = $classes->fetch_assoc()) { ?>
<option value="<?php echo $row['MaLop']; ?>"><?php echo $row['TenLop']; ?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<label for="dob">Date of Birth:</label>
<input type="date" id="dob" name="dob" class="form-control" required>
</div>
<div class="form-group">
<label for="address">Address:</label>
<input type="text" id="address" name="address" class="form-control" required>
</div>
<div class="form-group">
<label for="gender">Gender:</label><br>
<input type="radio" id="male" name="gender" value="Male" required>
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="Female" required>
<label for="female">Female</label>
</div>
<div class="form-group d-flex justify-content-center">
<input type="submit" value="Add Student" class="btn btn-primary">
</div>
</form>
</div>
<?php include 'templates/footer.php'; ?>