<?php
require_once __DIR__ . '/../db/db.php';
require_once __DIR__ . '/../includes/locations.php';

$country = $_GET['country'] ?? 'India';
$country = is_string($country) ? trim($country) : 'India';
if ($country === '') {
    $country = 'India';
}

$states = get_locations($conn, $country);
header('Content-Type: application/json');
echo json_encode([
    'country' => $country,
    'states' => $states
]);
?>



