<?php
$host = getenv('DB_HOST') ?: 'localhost';
$dbname = getenv('DB_DATABASE') ?: 'spbu_db'; // Change if your database name is different
$username = getenv('DB_USERNAME') ?: 'root';  // Default XAMPP username
$password = getenv('DB_PASSWORD') !== false ? getenv('DB_PASSWORD') : '';      // Default XAMPP password is empty

try {
    $pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
    die("Database connection failed: " . $e->getMessage());
}
?>