Spaces:
Running
Running
Commit History
-
<?php
Verified signaturesession_start(); include 'db.php'; include 'header.php'; if (!isset($_SESSION['user_id'])) { header("Location: index.html"); exit(); } $user_id = (int)$_SESSION['user_id']; if (!isset($_SESSION['current_session'])) { $sqlLast = "SELECT MAX(session_id) AS last FROM chat_logs WHERE user_id = $user_id"; $resLast = mysqli_query($conn, $sqlLast); $rowLast = mysqli_fetch_assoc($resLast); $active_session = ($rowLast['last'] ?? 0) + 1; $_SESSION['current_session'] = $active_session; } else { $active_session = $_SESSION['current_session']; } // FETCH TOPICS GROUPED BY CATEGORY $sqlTopics = "SELECT category, user_query FROM chatbot_responses ORDER BY category ASC, user_query ASC"; $resTopics = mysqli_query($conn, $sqlTopics); $categorizedTopics = []; while ($row = mysqli_fetch_assoc($resTopics)) { $cat = $row['category'] ?: 'General'; $categorizedTopics[$cat][] = $row['user_query']; } // FETCH PREVIOUS SESSIONS ("Your Chats" history) $sqlS…659d490