<?php
session_start();
echo "<pre>";
print_r($_SESSION);
echo "</pre>";

// Check connection
require_once 'connect.php';
echo "<h3>Database Check:</h3>";

// Check if employee exists in employees table using CNIC
if (isset($_SESSION['cnic'])) {
    $cnic = $_SESSION['cnic'];
    $sql = "SELECT * FROM employees WHERE cnic = '$cnic'";
    $result = $conn->query($sql);
    
    if ($result) {
        echo "Found in employees table: " . $result->num_rows . " records<br>";
        if ($result->num_rows > 0) {
            $row = $result->fetch_assoc();
            echo "<pre>";
            print_r($row);
            echo "</pre>";
        }
    }
}

// Check what's in registrations_emp
if (isset($_SESSION['employee_id'])) {
    $emp_id = $_SESSION['employee_id'];
    $sql = "SELECT * FROM registrations_emp WHERE id = $emp_id";
    $result = $conn->query($sql);
    
    if ($result && $result->num_rows > 0) {
        $row = $result->fetch_assoc();
        echo "<h3>From registrations_emp:</h3>";
        echo "<pre>";
        print_r($row);
        echo "</pre>";
    }
}
?>