<?php
require_once "connection.php";
if(isset($_GET['phoneNumber'])){
    $sql = "select idUser, namaLengkap, nik, jenisKelamin, ttl, alamat, phoneNumber from nasabah where phoneNumber ='".$_GET['phoneNumber']."'";
    if(!$con->query($sql)){
        echo "Error in executing query.";
    }else{
        $result = $con->query($sql);
        if($result->num_rows > 0){
            $return_arr['nasabah'] = array();
            while($row = $result->fetch_array()){
                array_push($return_arr['nasabah'], array(
                    'id'=>$row['idUser'],
                    'fullName'=>strtoupper($row['namaLengkap']), // Convert fullName to uppercase
                    'nik'=>$row['nik'],
                    'sex'=>$row['jenisKelamin'],
                    'ttl'=>$row['ttl'],
                    'address'=>$row['address'],
                    'phoneNumber'=>$row['phoneNumber']
                ));
            }
            echo json_encode($return_arr);
        }
    }
}
?>
