Fixed JSON error handling in load-responses.php

This commit is contained in:
overplayed 2025-03-15 19:23:42 -04:00
parent 5fcc4d0e74
commit 3c5779ce35
1 changed files with 5 additions and 4 deletions

View File

@ -10,16 +10,17 @@ $userToken = $_SESSION['user_token'] ?? $_GET['token'] ?? null;
if (!$userToken) {
http_response_code(403);
echo json_encode(["error" => "Unauthorized access."]);
exit;
echo json_encode(["error" => "Invalid authentication token: " . htmlspecialchars($userToken)]);
exit;
}
// Connect to the database
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($conn->connect_error) {
http_response_code(500);
echo json_encode(["error" => "Database connection failed."]);
exit;
echo json_encode(["error" => "Database connection failed: " . $conn->connect_error]);
exit;
}
// Fetch user ID using token