<?php
// Verification script to check DB connection and table setup
require_once 'includes/config.php';

echo "<h2>Database Verification</h2>";

try {
    // Check if table exists
    $stmt = $pdo->query("SHOW TABLES LIKE 'users'");
    if ($stmt->rowCount() > 0) {
        echo "<p style='color: green;'>✅ Table 'users' exists.</p>";
    } else {
        echo "<p style='color: red;'>❌ Table 'users' does not exist. Please run the SQL in migrations/database.sql</p>";
        
        // Attempt to create table automatically
        $sql = file_get_contents('migrations/database.sql');
        if ($sql) {
            $pdo->exec($sql);
            echo "<p style='color: green;'>✅ Table 'users' created successfully via automation.</p>";
        }
    }
} catch (PDOException $e) {
    echo "<p style='color: red;'>❌ Error: " . $e->getMessage() . "</p>";
    echo "<p>Please ensure your MySQL server (XAMPP) is running and the database 'gp_crackers' is created.</p>";
}
?>
<hr>
<p><a href="login.html">Go to Registration Page</a></p>
