-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_create_c.php
More file actions
153 lines (134 loc) · 5.19 KB
/
admin_create_c.php
File metadata and controls
153 lines (134 loc) · 5.19 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
require_once("models/header.php");
if (!empty($_POST)) {
$course_code = htmlspecialchars(stripcslashes(trim($_POST['course_code'])));
$course_name = htmlspecialchars(stripcslashes(trim($_POST['course_name'])));
$lecturer_name = htmlspecialchars(stripcslashes(trim($_POST['lecturer_name'])));
$cl_name = htmlspecialchars(stripcslashes(trim($_POST['cl_name'])));
$cm_name = htmlspecialchars(stripcslashes(trim($_POST['cm_name'])));
$faculty_id = htmlspecialchars(stripcslashes(trim($_POST['faculty_id'])));
if (!empty($lecturer_name) and !empty($cl_name) and !empty($cm_name) and !empty($faculty_id) and !empty($course_code) and strlen($course_code)<7 and !empty($course_name)) {
$addcourse = $mysqli->prepare("INSERT into course (course_code, lecturer_name, cl_name, cm_name, course_name, faculty_id) values ('$course_code', '$lecturer_name', '$cl_name', '$cm_name', '$course_name', '$faculty_id');");
$addcourse->execute();
$addcourse->close();
$successes[] = lang("COURSE_ADDED");
} else {
$errors[] = lang("WRONG_DATA");
}
}
$getlecturers = $mysqli->prepare("SELECT display_name FROM uc_users where id in (select user_id from uc_user_permission_matches where permission_id = '7');");
$getlecturers->execute();
$getlecturers->bind_result($lecturer_name);
while ($getlecturers->fetch()){
$lecturers[] = $lecturer_name;
}
$getlecturers->close();
$getleaders = $mysqli->prepare("SELECT display_name FROM uc_users where id in (select user_id from uc_user_permission_matches where permission_id = '4');");
$getleaders->execute();
$getleaders->bind_result($leader_name);
while ($getleaders->fetch()){
$leaders[] = $leader_name;
}
$getleaders->close();
$getmoders = $mysqli->prepare("SELECT display_name FROM uc_users where id in (select user_id from uc_user_permission_matches where permission_id = '5');");
$getmoders->execute();
$getmoders->bind_result($moder_name);
while ($getmoders->fetch()){
$moders[] = $moder_name;
}
$getmoders->close();
$getfaculties = $mysqli->prepare("SELECT faculty_id, faculty_name FROM faculty");
$getfaculties->execute();
$getfaculties->bind_result($faculty_id, $faculty_name);
while ($getfaculties->fetch()){
$faculties[] = array('faculty_id' => $faculty_id, 'faculty_name' => $faculty_name);
}
$getfaculties->close();
echo "
</div>
<div id='main' class='col-md-10'>";
echo resultBlock($errors,$successes);
echo "
<div id='regbox'><h1>Create course:</h1>
<form name='admincourses' action='".$_SERVER['PHP_SELF']."' method='post' class='form-horizontal'>
<fieldset>
<!-- Text input-->
<div class='form-group'>
<label class='col-md-2 control-label' for='course_code'>Code:</label>
<div class='col-md-4'>
<input id='course_code' name='course_code' placeholder='C12345' class='form-control input-md' required=' type='text'>
</div>
</div>
<!-- Text input-->
<div class='form-group'>
<label class='col-md-2 control-label' for='course_name'>Name:</label>
<div class='col-md-4'>
<input id='course_name' name='course_name' placeholder='...' class='form-control input-md' required=' type='text'>
</div>
</div>
<!-- Select Basic -->
<div class='form-group'>
<label class='col-md-2 control-label' for='lecturer_name'>Lecturer:</label>
<div class='col-md-4'>
<select id='lecturer_name' name='lecturer_name' class='form-control'>
<option value=''>- select lecturer -</option>";
foreach ($lecturers as $lecturer) {
echo "<option value='$lecturer'>$lecturer</option>";
}
echo "</select>
</div>
</div>
<!-- Select Basic -->
<div class='form-group'>
<label class='col-md-2 control-label' for='cl_name'>Leader:</label>
<div class='col-md-4'>
<select id='cl_name' name='cl_name' class='form-control'>
<option value=''>- select leader -</option>";
foreach ($leaders as $leader) {
echo "<option value='$leader'>$leader</option>";
}
echo "</select>
</div>
</div>
<!-- Select Basic -->
<div class='form-group'>
<label class='col-md-2 control-label' for='cm_name'>Moderator:</label>
<div class='col-md-4'>
<select id='cm_name' name='cm_name' class='form-control'>
<option value=''>- select moderator -</option>";
foreach ($moders as $moder) {
echo "<option value='$moder'>$moder</option>";
}
echo "</select>
</div>
</div>
<!-- Select Basic -->
<div class='form-group'>
<label class='col-md-2 control-label' for='faculty_name'>Faculty:</label>
<div class='col-md-4'>
<select id='faculty_name' name='faculty_id' class='form-control'>
<option value=''>- select faculty -</option>";
foreach ($faculties as $faculty) {
echo "<option value='".$faculty['faculty_id']."'>".$faculty['faculty_name']."</option>";
}
echo "</select>
</div>
</div>
<!-- Button -->
<div class='form-group'>
<label class='col-md-2 control-label' for='submit'></label>
<div class='col-md-4'>
<button id='submit' name='submit' class='btn btn-primary'>Submit</button>
</div>
</div>
</fieldset>
</form>";
echo" </div>
</div>
</div>
<div id='bottom'></div>
</div>
</body>
</html>";