<?php
function getUserCountry() {
    $ip = $_SERVER['REMOTE_ADDR'];

    // Use a free geolocation API
    $url = "http://ip-api.com/json/$ip";
    $response = file_get_contents($url);
    $data = json_decode($response, true);

    return $data['country'] ?? 'Unknown';
}
?>
