26 lines
868 B
PHP
26 lines
868 B
PHP
<?php
|
|
// Database configuration
|
|
define('DB_HOST', 'localhost');
|
|
define('DB_USER', 'root');
|
|
define('DB_PASS', '@Samui@10742'); // Change this based on your local setup (e.g., empty string for XAMPP default)
|
|
define('DB_NAME', 'it_ot');
|
|
|
|
// App Password
|
|
define('APP_PASSWORD', 'ijawa');
|
|
|
|
try {
|
|
$pdo = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=utf8mb4", DB_USER, DB_PASS);
|
|
// Set PDO error mode to exception
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
// Set default fetch mode to associative array
|
|
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
|
} catch (PDOException $e) {
|
|
die(json_encode([
|
|
'status' => 'error',
|
|
'message' => 'Connection failed: ' . $e->getMessage()
|
|
]));
|
|
}
|
|
|
|
// Ensure the response is JSON
|
|
header('Content-Type: application/json; charset=utf-8');
|