<?php
// Force PHP to display errors directly on the screen
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Start the session cleanly
session_start();

$message = "";

// Handle a simple, hardcoded form submission
if (isset($_POST['test_submit'])) {
    $username = $_POST['username'] ?? '';
    $password = $_POST['password'] ?? '';

    // Hardcoded check just to see if logic flows
    if ($username === 'admin' && $password === 'password123') {
        $_SESSION['test_user'] = 'Logged In Successfully!';
        $message = "<div style='color: green;'>Success! Session created.</div>";
    } else {
        $message = "<div style='color: red;'>Wrong username or password. (Try admin / password123)</div>";
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Simple PHP Test</title>
</head>
<body style="font-family: Arial, sans-serif; margin: 50px;">

    <h2>Diagnostic Test Page</h2>
    <p>If you can see this page, your PHP server is working, and the 500 error is gone.</p>
    
    <?php if (!empty($message)) echo $message; ?>

    <form method="POST" action="test_login.php" style="margin-top: 20px;">
        <div>
            <label>Username:</label><br>
            <input type="text" name="username" required>
        </div>
        <br>
        <div>
            <label>Password:</label><br>
            <input type="password" name="password" required>
        </div>
        <br>
        <button type="submit" name="test_submit">Test Login</button>
    </form>

    <hr style="margin-top: 40px;">
    <h3>Current Session Data:</h3>
    <pre><?php print_r($_SESSION); ?></pre>

</body>
</html>