<?php
// Enable error reporting to see any issues
error_reporting(E_ALL);
ini_set('display_errors', 1);

session_start();
require_once 'config/database.php';

// Check if user is already logged in
if (isset($_SESSION['student_logged_in']) && $_SESSION['student_logged_in'] === true) {
    header('Location: student_dashboard.php');
    exit();
}

echo "<h2>Debug Info for Student Login Page</h2>";

// Check database connection
if (isset($pdo)) {
    echo "<p style='color: green;'>✓ Database connection successful</p>";
} else {
    echo "<p style='color: red;'>✗ Database connection failed</p>";
}

// Check if admission_applications table exists
try {
    $stmt = $pdo->query("SELECT COUNT(*) FROM admission_applications");
    echo "<p style='color: green;'>✓ admission_applications table exists</p>";
} catch (Exception $e) {
    echo "<p style='color: red;'>✗ admission_applications table error: " . $e->getMessage() . "</p>";
}

// Check session
echo "<p>Session status: " . session_status() . "</p>";
echo "<p>Student logged in session: " . (isset($_SESSION['student_logged_in']) ? $_SESSION['student_logged_in'] : 'Not set') . "</p>";

// Include the actual login form
include 'student_login.php';
?>