-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_group.php
More file actions
67 lines (54 loc) · 1.87 KB
/
Copy pathcreate_group.php
File metadata and controls
67 lines (54 loc) · 1.87 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create Group</title>
</head>
<body>
<h1>Create a New Group</h1>
<?php
include_once "./protected/ensureLoggedIn.php";
include_once "./protected/connSql.php";
$stmt = $conn->prepare("SELECT classes.id, classes.name FROM classes JOIN
(
SELECT classId FROM linkUserClass WHERE userId = ?
) subquery
ON classes.id = subquery.classId
JOIN users
ON classes.teacherId = users.id;");
$stmt->bind_param("s", $_SESSION["userId"]);
$stmt->execute();
$stmt->bind_result($classId, $className);
$classCount = 0;
?>
<form action="process_create_group.php" method="POST" enctype="multipart/form-data">
<label for="groupName">Group Name:</label>
<input type="text" id="groupName" name="groupName" required>
<label for="groupDescription">Group Description:</label>
<textarea id="groupDescription" name="groupDescription" required></textarea>
<label for="groupPhoto">Group Photo:</label>
<input type="file" id="groupPhoto" name="groupPhoto" accept="image/*">
<label for="classId">Select Class:</label>
<select id="classId" name="classId" required>
<?php
while ($stmt->fetch()) {
echo "<option value=\"$classId\">$className</option>";
$classCount++;
}
?>
</select>
<input type="hidden" name="userRole" value="<?php echo $_SESSION["role"]; ?>">
<?php
if ($classCount === 0) {
echo "<p style=\"color:black\">You are not enrolled in any classes.</p>";
}
?>
<button type="submit">Create Group</button>
</form>
<?php
$stmt->close();
$conn->close();
?>
</body>
</html>