<?php
require_once 'config.php';
session_start();

// Debug the profile issue
if (!isset($_SESSION['user_id'])) {
    echo json_encode(['error' => 'Not logged in']);
    exit;
}

$user_id = $_SESSION['user_id'];
$user_type = $_SESSION['user_type'] ?? 'unknown';

echo "User ID: " . $user_id . "\n";
echo "User Type: " . $user_type . "\n";

// Check if admin in users table
$query1 = "SELECT * FROM users WHERE id = $user_id";
$result1 = $conn->query($query1);
if ($result1 && $result1->num_rows > 0) {
    $user = $result1->fetch_assoc();
    echo "Found in users table: " . json_encode($user) . "\n";
}

// Check if admin in staff table
$query2 = "SELECT * FROM staff WHERE id = $user_id";
$result2 = $conn->query($query2);
if ($result2 && $result2->num_rows > 0) {
    $staff = $result2->fetch_assoc();
    echo "Found in staff table: " . json_encode($staff) . "\n";
}
?>
