-
Notifications
You must be signed in to change notification settings - Fork 0
/
classtools.php
95 lines (82 loc) · 3.02 KB
/
classtools.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
<!DOCTYPE HTML>
<?php
include_once 'conf.php';
include_once 'dal/mysql.php';
if(!isset($_POST['Submit']))
{
include_once 'includes/header.php';
if (!$session->logged_in)
die("Not logged in.");
$name = "";
$desc = "";
if(!empty($_GET['classid']))
{
$prodigyDB = new mysqlDAL;
foreach ($prodigyDB->getClass($_GET["classid"]) as $row){
$class = $_GET['classid'];
$name = $row['name'];
$desc = $row['description'];
}
}
?>
<div id="wrapper" class="frame">
<div class="oneColumn">
<div class="classpage">
<form name="input" action="classtools.php" method="post">
<?php
if (empty($_GET['classid'])){
echo("<h3 class='header'>Create Your Class</h3>");
}else{
echo("<h3 class='header'>Editing ".$name."</h3>");
}
?>
<div class="module" style="margin-top: 15px;">
<table class="tableCreateClass">
<tr>
<td>Class Name:</td>
<td> <input type="text" size="35" name="name" value="<?php if(!empty($name)) echo $name; ?>" /></td>
<tr>
<tr>
<td>Description:</td>
<td><textarea name="description" rows="5" cols="50"><?php if(!empty($desc)) echo $desc; ?></textarea>
</tr>
<tr>
<td colspan="2">
<?php
if (empty($_GET['classid'])){
echo("<input type='submit' class='button' value='Create Class' style='margin: 5px;' name='Submit'/>");
}else{
echo("<input type='submit' class='button' value='Edit Class' style='margin: 5px;' name='Submit'/>");
}
?>
<?php if(!empty($_GET['classid'])) { ?> <input type="hidden" name="ClassId" value="<?php echo $_GET['classid']; ?>" /> <?php } ?>
</td>
</tr>
</table>
</div>
</form>
</div>
</div>
</div> <!--#wrapper -->
<?php
include_once 'includes/footer.php';
}
else
{
if(!empty($_POST['name']) && !empty($_POST['description']))
{
$db = new mysqlDAL;
if(isset($_POST['ClassId']))
{
$db->editClass($_POST['ClassId'], $_POST['name'], $_POST['description']);
$cID = $_POST['ClassId'];
echo "<meta http-equiv='refresh' content='0;url=index.php?module=viewclass&classid=".$cID."'>";
}
else
{
$db->addClass($_POST['name'], $_POST['description']);
echo "<meta http-equiv='refresh' content='0;url=index.php?module=viewcatalog'>";
}
}
}
?>