<?php
// // Konfigurasi Database
// $host = 'localhost';
// $user = 'root';
// $pass = '';
// $db   = 'pos_m';

// // Buat koneksi
// $conn = new mysqli($host, $user, $pass, $db);

include_once '../data.php';
$conn = new mysqli($servername, $username, $password, $dbname);

$host = $servername;
$user = $username;
$pass = $password;
$db   = $dbname;
// Cek koneksi
if ($conn->connect_error) {
    // Hentikan script dan beri pesan error jika koneksi gagal
    header('Content-Type: application/json');
    http_response_code(500); // Internal Server Error
    echo json_encode([
        'status' => 'error',
        'message' => 'Koneksi database gagal: ' . $conn->connect_error
    ]);
    exit();
}

// Set karakter set ke utf8
$conn->set_charset("utf8");
?>