-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert.php
executable file
·69 lines (68 loc) · 2.55 KB
/
insert.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
<?php ob_start(); ?>
<?php
session_start();
if(!isset($_SESSION['cwid']))
{
header("location:login.php");
}
?>
<!DOCTYPE html>
<html lang="en=US">
<head>
<title>Instructor</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="table.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="header.css">
</head>
<body bgcolor="#E6E6FA">
<?php
if(isset($_POST["course_id"]))
{
$course_id = addslashes(strip_tags($_POST["course_id"]));
if($_SESSION['admin_bool']==1)
{
include("headerInstructorAdvisor.php");
}
else
{
include("headerInstructor.php");
}
include("databaseClassMySQLi.php");
//include("projconfig.php");
$databaseObj=new database();
$databaseObj->setup(DB_USER,DB_PASS,DB_HOST,DB_NAME);
if(isset($_POST))
{
foreach($_POST as $key=>$value)
{
if(is_array($value))
{
$jsonData = "{\\\"$key\\\":[";
$numfiles = sizeof($value);
foreach($value as $element)
{
$jsonData = $jsonData.'\"'.$element.'\"';
if($numfiles!=1)
{
$jsonData = $jsonData.', ';
}
$numfiles = $numfiles-1;
}
$jsonData = $jsonData.']}';
$jsonDataString = $databaseObj->escape($jsonData);
//echo $jsonDataString;
$query = "insert into submissiontype(course_id, submission_type, refreshOnUpdate) values ('$course_id','$jsonDataString',false)";
$result = $databaseObj->send_sql($query);
}
}
}
echo "Course designed successfully";
}
else
{
header("location:designCourse.php");
}
?>
</body>
</html>