<?php
require_once 'db.php';
require_once '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
]);
?>
