<?php
// Automatically finds the absolute server directory of your 'dripend' folder
define('DRIPEND_PATH', dirname(__DIR__) . '/');

// 1. Detect the environment automatically
$isLocalhost = in_array($_SERVER['HTTP_HOST'], ['localhost', '127.0.0.1']);

if ($isLocalhost) {
    // Localhost Configuration (XAMPP)
    $host     = "localhost"; 
    $username = "kqmucpub_rimax"; // Change to "root" if XAMPP default is used
    $password = "RimaxHealthSuite@2026"; 
    $database = "kqmucpub_rimax";
} else {
    // Live Server Configuration (cPanel / Production)
    $host     = "localhost"; // Usually localhost on live servers too
    $username = "kqmucpub_rimax";     // 🔴 REPLACE WITH YOUR LIVE DB USERNAME
    $password = "RimaxHealthSuite@2026"; // 🔴 REPLACE WITH YOUR LIVE DB PASSWORD
    $database = "kqmucpub_rimax";     // 🔴 REPLACE WITH YOUR LIVE DB NAME


}

// 2. Create connection
$conn = new mysqli($host, $username, $password, $database);

// 3. Check connection
if ($conn->connect_error) {
    // Hide detailed error on live server for security, show it on local for debugging
    if ($isLocalhost) {
        die("Database Connection Failed: " . $conn->connect_error);
    } else {
        die("Database Connection Failed. Please contact the administrator.");
    }
}

// 4. Set charset to utf8mb4 for full Unicode support
$conn->set_charset("utf8mb4");


?>
