-
Notifications
You must be signed in to change notification settings - Fork 0
/
teacherclass.php
141 lines (116 loc) · 5.48 KB
/
teacherclass.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
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
<!DOCTYPE html>
<?php
include 'db.php';
include 'navi.php';
session_start();
$user = $_SESSION['user'];
if (!isset($_SESSION['user'])) {
echo "<script>window.location.href = 'index.php';</script>";
}
include 'submission.php';
$sqlstore = "SELECT * FROM user WHERE username = '$user'";
$resultstore = $conn->query($sqlstore);
$ln = '';
$fn = '';
$pass = '';
$userimage = '';
while ($rowstore = $resultstore->fetch_assoc()) {
$userimage = $rowstore['image'];
$ln = $rowstore['lastname'];
$fn = $rowstore['firstname'];
$pass = $rowstore['password'];
}
if (isset($_POST['myClass'])) {
$_SESSION['selectedclass'] = $_POST['myClass'];
echo "<script>window.location.href = 'teacherClassroom.php';</script>";
}
if (isset($_POST['createclass'])) {
$newclass = mysqli_real_escape_string($conn, $_POST['newclass']);
$sqlinsert = "INSERT INTO class (class_name, teacher) VALUES ('$newclass', '$user');";
$result = $conn->query($sqlinsert) or trigger_error("Query Failed! SQL: $sqlinsert - Error: " .mysqli_error(), E_USER_ERROR);
echo "<script>
alert('New Class Successfully Created!');
window.location.href = 'teacherclass.php';
</script>";
}
if (isset($_POST['removeclass'])) {
$removeclass = $_POST['removeclass'];
$sql = "DELETE FROM class WHERE class_id = '$removeclass'";
$result = $conn->query($sql) or trigger_error("Query Failed! SQL: $sql - Error: " .mysqli_error(), E_USER_ERROR);
echo "<script>alert('Class Remove Successfully!');</script>";
}
?>
<html>
<head>
<title>Essay Checker</title>
<link rel="stylesheet" type="text/css" href="css/maindesign.css">
<link class="jsbin" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
<meta charset=utf-8 />
</head>
<body>
<div id="container">
<div id="header">
<label style="top: 5px; left: 15px; font-size: 30px; position: absolute;">Vanguard Essay Checker</label>
</div>
<fieldset id="teachprofile">
<img src="<?= 'data:image/jpeg;base64,' .base64_encode($userimage) ?>" alt="No image" class="profimage" id="blah" />
<br /><br />
<label style="font-size: 15px; font-family: Arial, Charcoal, sans-serif;">ID: <?= $user ?></label>
</fieldset>
<fieldset id="classlist">
<form method="POST" action="#">
<br />
<p><label>Class List</label>
<input type="text" name="newclass" placeholder="Enter New Class Name" maxlength="100" style="margin-left: 340px;" required />
<input type="submit" name="createclass" value="Create" class="success" />
</p>
<br /><br />
</form>
<form method="POST" action="#">
<table style='margin-top: 0;'>
<tbody>
<?php
$sql3 = "SELECT * FROM class WHERE teacher = '$user'";
$result3 = $conn->query($sql3) or trigger_error("Query Failed! SQL: $sql3 - Error: " .mysqli_error(), E_USER_ERROR);
$num_rows = mysqli_num_rows($result3);
$arrCount = 0;
?>
<?php while ($rows = $result3->fetch_assoc()): ?>
<tr>
<?php $arrCount++; ?>
<?php if ($arrCount <= $num_rows): ?>
<td id="tdstyle">
<input type="image" src="img/classroom.jpg" id="classroom" name="myClass" value="<?= $rows['class_id'] ?>" />
<br />
<label>Code:<?= $rows['class_id'] ?></label>
<br />
<textarea id="tbllbl" disabled><?= $rows['class_name'] ?></textarea>
<br />
<input type="image" onclick="return confirm('Are you sure you want to delete this class?')" src="img/remove.png" name="removeclass" value="<?= $rows['class_id'] ?>" style="height: 15px; width: 15px; margin-top: 50px;" /><label style="color: gray; font-size: 12px;">Remove</label>
</td>
<?php $rows = $result3->fetch_assoc(); ?>
<?php else: ?>
<?php break; ?>
<?php endif; ?>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</form>
</fieldset>
</div>
</body>
</html>
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#blah').attr('src', e.target.result).width(235).height(200);
};
reader.readAsDataURL(input.files[0]);
}
}
</script>