<?php
include 'confing.php'; 

$response = array();

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $phone = $_POST['user_id'];

    if (empty($phone)) {
        $response['status'] = 'error';
        $response['message'] = 'Phone Number';
    } else {
        $query = "SELECT * FROM user_details WHERE id = '$phone'";
        $result = mysqli_query($conn, $query);

        if (mysqli_num_rows($result) > 0) {
            $user = mysqli_fetch_assoc($result);
            $response['status'] = 'success';
            $response['user_data'] = $user;
        } else {
            $response['status'] = 'error';
            $response['message'] = 'No Data Found';
        }
    }
} else {
    $response['status'] = 'error';
    $response['message'] = 'Bad Request';
}

echo json_encode($response);
?>
