-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathassignmodule.php
More file actions
48 lines (37 loc) · 1.53 KB
/
assignmodule.php
File metadata and controls
48 lines (37 loc) · 1.53 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
<?php
include("_includes/config.inc");
include("_includes/dbconnect.inc");
include("_includes/functions.inc");
// check logged in
if (isset($_SESSION['id'])) {
echo template("templates/partials/header.php");
echo template("templates/partials/nav.php");
// If a module has been selected
if (isset($_POST['selmodule'])) {
$sql = "insert into studentmodules values ('" . $_SESSION['id'] . "','" . $_POST['selmodule'] . "');";
$result = mysqli_query($conn, $sql);
$data['content'] .= "<p>The module " . $_POST['selmodule'] . " has been assigned to you</p>";
}
else // If a module has not been selected
{
// Build sql statment that selects all the modules
$sql = "select * from module";
$result = mysqli_query($conn, $sql);
$data['content'] .= "<form name='frmassignmodule' action='' method='post' >";
$data['content'] .= "Select a module to assign<br/>";
$data['content'] .= "<select name='selmodule' >";
// Display the module name sin a drop down selection box
while($row = mysqli_fetch_array($result)) {
$data['content'] .= "<option value='$row[modulecode]'>$row[name]</option>";
}
$data['content'] .= "</select><br/>";
$data['content'] .= "<input type='submit' name='confirm' value='Save' />";
$data['content'] .= "</form>";
}
// render the template
echo template("templates/default.php", $data);
} else {
header("Location: index.php");
}
echo template("templates/partials/footer.php");
?>