-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditclass.php
More file actions
73 lines (64 loc) · 1.85 KB
/
editclass.php
File metadata and controls
73 lines (64 loc) · 1.85 KB
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
<?php
require_once("checkuser.php");
require_once("connect.php");
require 'libs/Smarty.class.php';
$prof = '';
$department = '';
$code = '';
$code = '';
$section = '';
$exam = '';
$halftime = '';
$db = db_connect();
$stmt = $db->stmt_init();
if (isset($_POST['prof']))
{
$update = false;
if ($stmt->prepare("SELECT * FROM course WHERE id=?"))
{
$stmt->bind_param('i',$_SESSION['user']);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0)
$update = true;
$stmt->free_result();
}
if ($update)
{
if ($stmt->prepare("UPDATE course SET department=?,code=?,section=?,exam=?,halftime=?,prof=? WHERE id=?"))
{
$stmt->bind_param('sissssi',$_POST['department'],$_POST['code'],$_POST['section'],$_POST['exam'],$_POST['halftime'],$_POST['prof'],$_SESSION['user']);
$stmt->execute();
}
}else
{
if ($stmt->prepare("INSERT INTO course (id,department,code,section,exam,halftime,prof) VALUES (?,?,?,?,?,?,?)"))
{
$stmt->bind_param('isissss',$_SESSION['user'],$_POST['department'],$_POST['code'],$_POST['section'],$_POST['exam'],$_POST['halftime'],$_POST['prof']);
$stmt->execute();
}
}
}
if ($stmt->prepare("SELECT prof,department,code,section,exam,halftime FROM course WHERE id=?"))
{
$stmt->bind_param('i',$_SESSION['user']);
$stmt->execute();
$stmt->bind_result($prof,$department,$code,$section,$exam,$halftime);
$stmt->fetch();
$stmt->close();
}
$db->close();
$smarty = new Smarty;
//$smarty->force_compile = true;
//$smarty->debugging = true;
//$smarty->caching = true;
//$smarty->cache_lifetime = 120;
$smarty->assign('title','Class Editor');
$smarty->assign('prof',$prof);
$smarty->assign('department',$department);
$smarty->assign('code',$code);
$smarty->assign('section',$section);
$smarty->assign('exam',$exam);
$smarty->assign('halftime',$halftime);
$smarty->display('editclass.tpl');
?>