-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_live_class.php
More file actions
40 lines (33 loc) · 924 Bytes
/
Copy pathstart_live_class.php
File metadata and controls
40 lines (33 loc) · 924 Bytes
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
<?php
session_start();
require "config.php";
if (!isset($_SESSION['id']) || $_SESSION['role'] !== 'teacher') {
die("Access denied");
}
$class_id = (int)($_GET['id'] ?? 0);
if ($class_id <= 0) {
die("Invalid class ID");
}
/* ===========================
GET TEACHER.ID
=========================== */
$stmt = $pdo->prepare("SELECT id FROM teachers WHERE user_id = ?");
$stmt->execute([$_SESSION['id']]);
$teacher_id = $stmt->fetchColumn();
if (!$teacher_id) {
die("Teacher profile not found");
}
/* ===========================
START LIVE CLASS
=========================== */
$stmt = $pdo->prepare("
UPDATE live_classes
SET status = 'live'
WHERE id = ? AND teacher_id = ?
");
$stmt->execute([$class_id, $teacher_id]);
if ($stmt->rowCount() === 0) {
die("Unable to start live class");
}
header("Location: live_class_room.php?id=$class_id");
exit;