-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase_controller.php
298 lines (217 loc) · 9.51 KB
/
database_controller.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
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
<?php
session_start();
include("connection.php");
// session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['submit_login'])) {
$email = $_POST['admin_email'];
$pass = $_POST['admin_pass'];
$sql_restrict= "SELECT * FROM admin WHERE Admin_email = '$email' and password ='$pass' ";
$result_restrict= mysqli_query($connection,$sql_restrict) or die("Query Uncessfull");
if(mysqli_num_rows($result_restrict) > 0){
// echo "successful";
// echo
$_SESSION['admin'] = $email;
echo "<script>window.open('mitaoe.php', '_self')</script>";
}else{
echo"Please, Enter correct email and password!!! ";
}
}
}
// if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// if (isset($_POST['signin'])) {
// $email = $_POST['admin_email'];
// $pass = $_POST['your_pass'];
// $sql_restrict= "SELECT * FROM admin WHERE email = '$email' and password ='$pass' ";
// $result_restrict= mysqli_query($connection,$sql_restrict) or die("Query Uncessfull");
// if(mysqli_num_rows($result_restrict) > 0){
// echo "successful";
// // echo "<script>window.open('mitaoe.php')</script>";
// }else{
// echo"Please, Enter correct email and password!!! ";
// }
// }
// }
// To restrict Student
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['restrict_student'])) {
$email = $_POST['student_email'];
// $fill_date = date("Y-m-d");
// $sql_home="INSERT INTO student( student_email, fill_date) VALUES ( '$email','$fill_date')";
// mysqli_query(createConn(),$sql_home);
$sql_restrict= "SELECT * FROM student WHERE student_email = '$email'";
$result_restrict= mysqli_query($connection,$sql_restrict) or die("Query Uncessfull");
// $sql_restrict;
if(mysqli_num_rows($result_restrict) > 0){
echo "You have already given feedback";
// print_r($result_restrict);
}
else{
echo "<script>window.open('feedback.html', '_self')</script>";
}
// echo "<script>window.open('feedback.html', '_self')</script>";
}
}
// Adding Faculty course allocation to table
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['submit_add_course_allocation'])) {
$faculty_name=$_POST['faculty_name'];
$faculty_email=$_POST['faculty_email'];
$subject_name=$_POST['subject_name'];
$subject_short_name=$_POST['subject_short_name'];
$subject_type=$_POST['subject_type'];
$division=$_POST['division'];
$batch=$_POST['batch'];
$sql_home="
INSERT INTO course_allocation( faculty_name, faculty_email,subject_name, subject_short_name, subject_type, batch, division)
VALUES ( '$faculty_name','$faculty_email' ,'$subject_name' ,'$subject_short_name' ,'$subject_type' ,'$division' ,'$batch')";
mysqli_query(createConn(),$sql_home);
echo "<script>window.open('course_allocation.php', '_self')</script>";
}
}
// To edit faculty course allocation
if (isset($_POST['submit_edit_course_allocation'])) {
$faculty_course_id = $_POST['course_allocation_id'];
$faculty_name=$_POST['faculty_name'];
$faculty_email=$_POST['faculty_email'];
$subject_name=$_POST['subject_name'];
$subject_short_name=$_POST['subject_short_name'];
$subject_type=$_POST['subject_type'];
$division=$_POST['division'];
$batch=$_POST['batch'];
mysqli_query($connection, "UPDATE course_allocation SET faculty_name='$faculty_name ', faculty_email='$faculty_email' , subject_name='$subject_name' , subject_short_name ='$subject_short_name' , subject_type ='$subject_type' , batch='$batch' , division ='$division' WHERE id=$faculty_course_id");
echo "<script>window.open('course_allocation.php', '_self')</script>";
}
// Adding Students to table
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['submit_add_student'])) {
// $name=$_POST['faculty_name'];
// $branch=$_POST['faculty_branch'];
$student_name= $_POST['student_name'];
$student_prn= $_POST['student_prn'];
$student_email= $_POST['student_email'];
$branch= $_POST['branch'];
$division= $_POST['division'];
$year= $_POST['year'];
$addmission_year= $_POST['addmission_year'];
// $response= $_POST['response'];
$sql_home="INSERT INTO students( name, prn, email, branch, division, year, addmission_year, response) VALUES ( '$student_name' ,'$student_prn' ,'$student_email' ,'$branch' ,'$division' ,'$year' ,'$addmission_year' ,'0')";
mysqli_query(createConn(),$sql_home);
echo "<script>window.open('students.php', '_self')</script>";
}
}
// To edit Students
if (isset($_POST['submit_edit_student'])) {
$student_id = $_POST['student_id'];
$student_name= $_POST['student_name'];
$student_prn= $_POST['student_prn'];
$student_email= $_POST['student_email'];
$branch= $_POST['branch'];
$division= $_POST['division'];
$year= $_POST['year'];
$addmission_year= $_POST['addmission_year'];
// $response= $_POST['response'];
mysqli_query($connection, "UPDATE students SET name='$student_name' , prn='$student_prn' , email='$student_email' , branch='$branch' , division='$division' , year='$year' , addmission_year='$addmission_year' , response='0' WHERE student_id=$student_id");
echo "<script>window.open('students.php', '_self')</script>";
}
// Adding faculty to table
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['submit_add_faculty'])) {
$name=$_POST['faculty_name'];
$branch=$_POST['faculty_branch'];
$sql_home="INSERT INTO faculty( name, department) VALUES ( '$name','$branch')";
mysqli_query(createConn(),$sql_home);
echo "<script>window.open('faculty_admin.php', '_self')</script>";
}
}
// To edit faculty
if (isset($_POST['submit_edit_faculty'])) {
$faculty_id = $_POST['faculty_id'];
$faculty_name = $_POST['faculty_name'];
$new_banch = $_POST['faculty_branch'];
mysqli_query($connection, "UPDATE faculty SET name='$faculty_name', department='$new_banch' WHERE id=$faculty_id");
echo "<script>window.open('faculty_admin.php', '_self')</script>";
}
// Adding course to table
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['submit_add_course'])) {
$name=$_POST['course_name'];
$branch=$_POST['course_branch'];
$sql_home="INSERT INTO course( name, branch) VALUES ( '$name','$branch')";
mysqli_query(createConn(),$sql_home);
echo "<script>window.open('course_admin.php', '_self')</script>";
}
}
// To edit course
if (isset($_POST['submit_edit_course'])) {
$course_id = $_POST['course_id'];
$course_name = $_POST['course_name'];
$new_banch = $_POST['course_branch'];
mysqli_query($connection, "UPDATE course SET name='$course_name', branch='$new_banch' WHERE id=$course_id");
echo "<script>window.open('course_admin.php', '_self')</script>";
}
// function add_faculty($id, $name)
// {
// $conn = createConn();
// $sql = $conn->prepare("INSERT INTO faculty (id, name) VALUES ('$id' , '$name')");
// $sql->bind_param("is", $id, $name);
// if ($sql->execute()) {
// $success = 1;
// } else {
// $success = -1;
// }
// }
// function fetch_courses($branch, $batch, $division, $semester)
// {
// $conn = createConn();
// $sql = $conn->prepare("SELECT * FROM course_allocation where branch = ? and semester = ? and (batch = ? or batch = ?);");
// $sql->bind_param("siss", $branch, $semester, $division, $batch);
// $result = $conn->query($sql);
// if ($result->num_rows > 0) {
// while ($row = $result->fetch_assoc()) {
// $course_name = get_course_name($row['course_id']);
// $faculty_name = get_faculty_name($row['faculty_id']);
// $feedback[$course_name] = $faculty_name;
// }
// return $feedback;
// } else {
// return "Invalid batch or branch";
// }
// }
// function get_course_name($course_id)
// {
// $conn = createConn();
// $sql = $conn->prepare("SELECT name FROM course where id = ?");
// $sql->bind_param("i", $course_id);
// $sql->execute();
// if ($sql->num_rows > 0) {
// $result = $sql->get_result();
// while ($data = $result->fetch_assoc()) {
// return $data['name'];
// }
// } else {
// return -1;
// }
// }
// function get_faculty_name($faculty_id)
// {
// $conn = createConn();
// $sql = $conn->prepare("SELECT name FROM faculty where id = ?");
// $sql->bind_param("i", $faculty_id);
// $sql->execute();
// if ($sql->num_rows > 0) {
// $result = $sql->get_result();
// while ($data = $result->fetch_assoc()) {
// return $data['name'];
// }
// } else {
// return -1;
// }
// }
// function save_feedback($feedback)
// {
// }
// function create_feedback($semester, $division)
// {
// }
// $conn = createConn();