-
Notifications
You must be signed in to change notification settings - Fork 0
/
teacherAddAsProcess.php
63 lines (45 loc) · 1.97 KB
/
teacherAddAsProcess.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
<?php
session_start();
require "connection.php";
if (isset($_SESSION["teacher"])) {
$teacher = $_SESSION["teacher"];
$gsId = $_POST["gsID"];
$Asname = $_POST["Asname"];
$Sdate = $_POST["Sdate"];
$Edate = $_POST["Edate"];
$Tdate = date("Y-m-d");
if (empty($Asname)) {
echo "Please enter a name";
} else if (empty($Sdate)) {
echo "Please enter start date";
} else if($Sdate < $Tdate){
echo "Please enter valid start date";
} else if (empty($Edate)) {
echo "Please enter end date";
}else if($Edate < $Sdate){
echo "Please enter valid end date";
} else {
if (isset($_FILES["AddAs"])) {
$uploadFile = $_FILES["AddAs"];
$extension = pathinfo($uploadFile["name"], PATHINFO_EXTENSION);
$fileex = $uploadFile["type"];
if (!in_array($extension, ['zip', 'pdf', 'docx'])) {
echo "Please Select a valid file.";
} else {
$uniC = uniqid();
$uploadFileName = "UploadFiles//" . $uniC . $uploadFile["name"];
$file_name = $uniC . $uploadFile["name"];
move_uploaded_file($uploadFile["tmp_name"], $uploadFileName);
if ($teacher["section_id"] == "4") { //A/L section
Database::iud("INSERT INTO `a/l_assignment` (`name`,`file`,`grade_has_a/l_subjects_id`,`start`,`end`) VALUES ('" . $Asname . "','" . $file_name . "','" . $gsId . "','" . $Sdate . "','" . $Edate . "')");
echo "Asssignment added successfully";
} else { //not A/L
Database::iud("INSERT INTO `assignment` (`name`,`file`,`grade_has_subject_id`,`start`,`end`) VALUES ('" . $Asname . "','" . $file_name . "','" . $gsId . "','" . $Sdate . "','" . $Edate . "')");
echo "Asssignment added successfully";
}
}
} else {
echo "Please select a file";
}
}
}