-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteacher-course-mapping.php
42 lines (40 loc) · 1.3 KB
/
teacher-course-mapping.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
<?php
session_start();
echo $_POST['course_selection'].$_POST['faculty_id'].$_POST['year'];
if(!isset($_POST['course_selection']) || !isset($_POST['faculty_id']) || ! isset($_POST['year'])){
session_destroy();
}
else{
$conn = mysqli_connect('localhost','root','','test7');
if($conn->connect_error){
echo "$conn->connect_error";
die("Connection Failed : ". $conn->connect_error);
}
else {
if(isset($_POST['course_selection']) && isset($_POST['year'])){
$result = $conn->query("SELECT sem_no FROM semester WHERE course_no='".$_POST['course_selection']."';");
if($row=$result->fetch_assoc()){
$insert = $conn->query("INSERT INTO `teacher's_subject` VALUES('".$_POST['faculty_id']."', '".$_POST['course_selection']."', ".$row['sem_no'].", ".$_POST['year'].");");
if($insert=== TRUE){
echo "<script>alert('Course added successfully');</script>";
}
else{
echo "<script>alert('Course not added or already exists');</script>";
}
}
else{
echo "<script>alert('Sem not added');</script>";
}
}
$conn->close();
}
}
session_start();
$_SESSION['FAC'] = $_POST['faculty_id'];
if($_SESSION['hod']){
header('Location: hod-dashboard.php');
}
else{
header("Location: dashboard-teacher.php");
}
?>