<?php
// db_connect.php

// Database credentials
$host = 'localhost';
$db = 'qnjgzjte_rgs_hris'; // Replace with your database name
$user = 'qnjgzjte_rgserve_hris_itadmin'; // Replace with your database username
$pass = 'FpBc~7jH6@RGServe2025@#$rL3@Q%'; // Replace with your database password
$charset = 'utf8mb4';


$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$options = [
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_EMULATE_PREPARES   => false,
];

$error_message = ''; // Initialize error message variable

try {
    // Create a new PDO instance
    $pdo = new PDO($dsn, $user, $pass, $options);
} catch (\PDOException $e) {
    // Handle database connection errors
    $error_message = "Database connection error: " . $e->getMessage();
}

// NOTE: This file does NOT call session_start() because it should be called 
// once at the very beginning of the main script (login.php).
?>