-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateClass.php
108 lines (99 loc) · 2.77 KB
/
createClass.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
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
define('INCLUDE_CHECK',true);
// Those two files can be included only if INCLUDE_CHECK is defined
require "includes/connect.php";
require 'includes/functions.php';
include 'includes/membersOnly.php';
function adderror($error){
global $errorarray;
$errorarray[] = $error;
}
function addsuccess($success){
global $successarray;
$successarray[] = $success;
}
if($_POST['save']){
$cansave = true;
$name = mysql_real_escape_string($_POST['classname']);
$des = mysql_real_escape_string($_POST['des']);
$pass = mysql_real_escape_string($_POST['pass']);
$owner = $_SESSION['id'];
if($name == ''){
adderror('No class name given.');
$cansave = false;
}
if($pass == ''){
$pass = null;
}
if($cansave == true){
$write = mysql_query("INSERT INTO classes (name, description, owner, password) VALUES ('$name','$des','$owner','$pass')");
if (!$write){
adderror("Error saving class");
}
else{
header( 'Location: classes.php' );
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Pencl - Coming Soon</title>
<link rel="stylesheet" type="text/css" href="css/reset.css" media="screen">
<link rel="stylesheet" type="text/css" href="css/styles.css" media="screen">
<link rel="stylesheet" type="text/css" href="css/book.css" media="screen">
<?php
//Put this at the end of the <head> tag to track
include 'includes/topbar_header.php';
include 'includes/tracker.php';
?>
</head>
<body>
<?php
//Must be first thing in the <body> tag to function correctly
include 'includes/topbar.php';
?>
<!--<div id="pagewide">-->
<div class="bookcontainer">
<div class="book">
<div class="page">
<?php
echo "<h1>Create a Class.</h1>";
if ($errorarray)
{
foreach($errorarray as $value)
echo "<p class='error'>$value</p>";
}
if ($successarray)
{
foreach($successarray as $svalue)
echo "<p class='success'>$svalue</p>";
}
unset($errorarray);
unset($successarray);
?>
<br>
<form class="clearfix" action="" method="post">
<div>
<label class="grey" for="classname">Class Name:</label>
<input class="field" type="text" name="classname" id="text" size="23" />
</div>
<div>
<label class="grey" for="Description">Description:</label>
<input class="field" type="text" name="des" id="text" size="23" />
</div>
<div>
<label class="grey" for="pass">Password(Optional):</label>
<input class="field" type="password" name="pass" id="password" size="23" />
</div>
<input type="submit" name="save" value="Save Class" />
<input type="button" name="cancel" value="Cancel" onClick="window.history.back()" />
</form>
<!--</div>-->
</div>
</div>
</div>
</body>
</html>