<?php
// Error reporting ko on karein taaki har galti dikhe
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

echo "<h1>Database Connection Test</h1>";

// config.php file ko include karein
require_once 'config.php';

// Check karein ki $conn variable bana hai ya nahi
if (isset($conn)) {
    // Check karein ki connection mein koi error to nahi hai
    if ($conn->connect_error) {
        echo "<p style='color: red; font-weight: bold;'>Connection FAILED: " . $conn->connect_error . "</p>";
        echo "<p>Please check your database username, password, and database name in <strong>config.php</strong> file.</p>";
    } else {
        echo "<p style='color: green; font-weight: bold;'>Connection Successful!</p>";
        echo "<p>Your PHP code is successfully connected to the MySQL database '<strong>" . $dbname . "</strong>'.</p>";
    }
} else {
    echo "<p style='color: red; font-weight: bold;'>Error: The \$conn variable was not found. Is the 'config.php' file included correctly?</p>";
}

?>