<?php
session_start();
include "../include/config.php";

if (!isset($_SESSION['email'])) {
    echo json_encode(['error' => 'Unauthorized']);
    exit;
}

$class_id = isset($_POST['class_id']) ? intval($_POST['class_id']) : 0;

$stmt = $conn->prepare("SELECT start_time FROM online_classes WHERE id = ?");
$stmt->bind_param("i", $class_id);
$stmt->execute();
$result = $stmt->get_result();

if ($row = $result->fetch_assoc()) {
    echo json_encode(['start_time' => $row['start_time']]);
} else {
    echo json_encode(['error' => 'Class not found']);
}
?>