<?php
require '../config.php'; // your DB connection

if(isset($_GET['username'])){

    $username = $_GET['username'];

    $stmt = $pdo->prepare("SELECT acc_no, currency FROM logins WHERE username = ?");
    $stmt->execute([$username]);

    $row = $stmt->fetch(PDO::FETCH_ASSOC);

    if($row){

        $rates = [
            1 => 1,
            2 => 1.25,
            3 => 1.1,
            // add your rates here
        ];

        $currencyNames = [
            1 => 'USD',
            2 => 'GBP',
            3 => 'EUR',
            4 => 'AUD',
            5 => 'CAD',
            6 => 'CNY',
            7 => 'ZAR',
            8 => 'NGN',
            9 => 'GHS',
            10 => 'JPY',
            11 => 'KRW',
            12 => 'TWD',
            13 => 'THB',
            14 => 'MYR',
            15 => 'BRL',
            16 => 'ARS',
            17 => 'PHP',
            18 => 'AED'
        ];

        $rate = $rates[$row['currency']] ?? 1;
        $cur = $currencyNames[$row['currency']] ?? 'USD';

        echo json_encode([
            "status" => "success",
            "acc_no" => $row['acc_no'],
            "currency" => $cur,
            "rate" => $rate
        ]);

    } else {
        echo json_encode(["status" => "error"]);
    }
}