forked from turawa/School-Information-System
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddTeacher.php
149 lines (126 loc) · 5.8 KB
/
addTeacher.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="assets/css/custom.css">
<title>School Information System</title>
</head>
<body>
<!-- Setting the head and title for the project -->
<h4 class="text-center">Database Information Assignment</h4>
<h2 class="text-center">School Information System</h2>
<div class="container">
<ol class="breadcrumb">
<li><a href="index.php">Home</a></li>
<li><a href="teachers.php">Teachers List</a></li>
<li class="active">Add Teacher</li>
</ol>
<div class="jumbotron">
<h3 class="cat-head text-info">Add Teacher</h3>
<?php
if($_POST){
// foreach ($_POST as $key => $value) {
// echo '<button class="btn btn-danger">' .$key. '</button>';
// echo '<button class="btn btn-danger">' .$value. '</button>';
// }
$servername = "localhost";
$username = "root";
$password = "";
$db = "school";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $db);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$surname = $_POST['surname'];
$midname = $_POST['midname'];
$firstname = $_POST['firstname'];
$doe = $_POST['doe'];
$gender = $_POST['gender'];
$section = $_POST['section'];
$gl = $_POST['gl'];
// fetch Teachers
$sql = "INSERT INTO teacher (surname, midname, firstname, doe, gender, section, dept, GL)
VALUES ('$surname', '$midname', '$firstname', '$doe', '$gender', '$section', 'teaching', '$gl')";
if ($conn->query($sql) === TRUE) {
$success = 1;
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
if($success === 1){
header('Location: teachers.php');
}else{
echo '<h3 class="text-danger text-center">There was an error adding Teacher</h3>';
}
}
?>
<form action="addTeacher.php" method="POST" class="form-horizontal">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Surname</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="surname">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">First Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="firstname">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Middle Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="midname">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Gender</label>
<div class="col-sm-10">
<div class="radio">
<input type="radio" name="gender" value="male" checked>Male
</div>
<div class="radio">
<input type="radio" name="gender" value="female">Female
</div>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Date of Employment</label>
<div class="col-sm-10">
<input type="date" class="form-control" name="doe">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Grade Level</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="gl">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Section</label>
<div class="col-sm-10">
<select class="form-control" name="section">
<option>Nursery</option>
<option>Primary</option>
<option>Junior Secondary</option>
<option>Senior Secondary</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-success pull-right">Add Teacher</button>
</div>
</div>
</form>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="assets/js/custom.js"></script>
</body>
</html>