Your webinar dashboard
+ + + +Hi — your seat is confirmed. Use the join button below when it is time to enter the webinar room.
+ +diff --git a/dashboard.php b/dashboard.php index 9e87d2e..768478b 100644 --- a/dashboard.php +++ b/dashboard.php @@ -2,125 +2,293 @@ session_start(); require_once 'db/config.php'; +if (isset($_GET['logout']) && $_GET['logout'] === '1') { + unset($_SESSION['user_id']); + session_regenerate_id(true); + header('Location: login.php'); + exit; +} + if (!isset($_SESSION['user_id'])) { header('Location: login.php'); exit; } +function format_dashboard_datetime(?string $scheduledAt, ?string $timezone): string { + if (!$scheduledAt) { + return 'Schedule to be announced'; + } + + try { + $date = new DateTime($scheduledAt, new DateTimeZone('UTC')); + if (!empty($timezone) && in_array($timezone, timezone_identifiers_list(), true)) { + $date->setTimezone(new DateTimeZone($timezone)); + return $date->format('l, F j, Y \a\t g:i A T'); + } + + return $date->format('l, F j, Y \a\t g:i A T'); + } catch (Throwable $e) { + return $scheduledAt; + } +} + $attendee = null; $webinar = null; $error = ''; - -$user_id = $_SESSION['user_id']; +$user_id = (int) $_SESSION['user_id']; try { - // Fetch attendee details - $stmt = db()->prepare("SELECT * FROM attendees WHERE id = ?"); + $stmt = db()->prepare('SELECT * FROM attendees WHERE id = ? AND deleted_at IS NULL'); $stmt->execute([$user_id]); - $attendee = $stmt->fetch(); + $attendee = $stmt->fetch(PDO::FETCH_ASSOC); if ($attendee) { - // Fetch webinar details - $stmt = db()->prepare("SELECT * FROM webinars WHERE id = ?"); - $stmt->execute([$attendee['webinar_id']]); - $webinar = $stmt->fetch(); + $stmt = db()->prepare('SELECT * FROM webinars WHERE id = ?'); + $stmt->execute([(int) $attendee['webinar_id']]); + $webinar = $stmt->fetch(PDO::FETCH_ASSOC); } else { - $error = 'Could not find your registration details.'; + $error = 'Could not find your active registration details.'; } } catch (PDOException $e) { - $error = 'Database error. Please try again later.'; + error_log('Dashboard load failed: ' . $e->getMessage()); + $error = 'Dashboard is temporarily unavailable. Please try again later.'; } +$participantName = trim((string) (($attendee['first_name'] ?? '') . ' ' . ($attendee['last_name'] ?? ''))); +$participantName = $participantName !== '' ? $participantName : ((string) ($attendee['email'] ?? 'Guest')); +$joinLink = $attendee ? 'join.php?id=' . rawurlencode(base64_encode((string) $attendee['id'])) : 'login.php'; +$webinarDate = $webinar ? format_dashboard_datetime($webinar['scheduled_at'] ?? null, $attendee['timezone'] ?? null) : 'Schedule to be announced'; ?>
-Hello, = htmlspecialchars($attendee['first_name']) ?>!
-You are registered for the following webinar:
-Hi — your seat is confirmed. Use the join button below when it is time to enter the webinar room.
+ +You are now joining the webinar: = htmlspecialchars($webinar['title']) ?>
-The webinar is scheduled for: = (new DateTime($webinar['scheduled_at']))->format('l, F j, Y \a\t g:i A T') ?>
-Your registration is active. When the live room is available, this page is where you can connect attendees to the webinar experience.
+ +