<?php
header('Content-Type: application/json');
require_once 'config.php';

$customer_id = $_GET['customer_id'] ?? '';
$userdetails = null;

if ($customer_id) {
    $stmt = $conn->prepare("SELECT customer_id, name, phone, addresses FROM customers WHERE customer_id = ? LIMIT 1");
    $stmt->bind_param("s", $customer_id);
    $stmt->execute();
    $result = $stmt->get_result();
    if ($row = $result->fetch_assoc()) {
        $userdetails = $row;
    }
    $stmt->close();
}

echo json_encode([
    'success' => true,
    'userdetails' => $userdetails
]);
