<?php
// Start session if not already started
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

// --- CSRF TOKEN (for POST actions like approve/reject) ---
// Generate once per session and reuse across pages.
if (empty($_SESSION['csrf_token'])) {
    $_SESSION['csrf_token'] = bin2hex(random_bytes(32));
}

// --- FILL IN YOUR DATABASE DETAILS HERE ---
$servername = "localhost";
$username = "attendance";          // Check your actual DB username (often NOT root on shared hosting)
$password = "Amni2012$"; // Put your real database password here
$dbname = "school_attendance";          // Put your real database name here

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Security Check
if (!isset($_SESSION['user_id'])) {
    header("Location: ../index.php"); 
    exit();
}
?>