<?php
// db.php

$host = 'localhost';
$db   = 'kopt7737_dsfbsfgdsf';
$user = 'kopt7737_fdghgbndgth'; // Ganti dengan username DB Anda
$pass = 'K7HuazDsWB@)'; // Ganti dengan password DB Anda
$charset = 'utf8mb4';

$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$options = [
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION, // Error mode
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,       // Fetch mode
    PDO::ATTR_EMULATE_PREPARES   => false,                  // Disable emulation
];

try {
     $pdo = new PDO($dsn, $user, $pass, $options);
} catch (\PDOException $e) {
     http_response_code(500);
     echo json_encode(['error' => 'Database connection failed']);
     exit;
}
?>
