<?php
// config.php - Database connection settings

// Database credentials
define('DB_SERVER', 'localhost'); // Your database server (usually 'localhost' for local setup)
define('DB_USERNAME', 'lbscrm_hostel_management');    // Your database username (default for XAMPP/WAMP/MAMP is 'root')
define('DB_PASSWORD', 'TH,NPNJ(Qnk@T;&s');        // Your database password (default for XAMPP/WAMP is empty, MAMP is 'root')
define('DB_NAME', 'lbscrm_hostel_management'); // The name of the database you created in phpMyAdmin

// Attempt to connect to MySQL database using PDO
try {
    $pdo = new PDO("mysql:host=" . DB_SERVER . ";dbname=" . DB_NAME, DB_USERNAME, DB_PASSWORD);
    // Set the PDO error mode to exception
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    // Set default fetch mode to associative array
    $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);

    // Optional: Echo a success message for debugging, remove in production
    // echo "Database connection successful!";

} catch (PDOException $e) {
    // If connection fails, stop script execution and display error
    die("ERROR: Could not connect. " . $e->getMessage());
}
?>