<?php
session_start();

// Define correct credentials (for simplicity, hardcoded here)
$correct_username = "GOURAV PAPA";
$correct_password = "0008";

// Check if the login form was submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = $_POST['username'];
    $password = $_POST['password'];

    // Validate credentials
    if ($username === $correct_username && $password === $correct_password) {
        // Set session variable
        $_SESSION['loggedin'] = true;
        // Redirect to home page
        header("Location: main.php");
        exit();
    } else {
        // Invalid credentials
        $error = "❌ ACCESS DENIED! Incorrect Credentials";
        // Redirect back to login page with error message
        header("Location: index.php?error=" . urlencode($error));
        exit();
    }
}
?>