<?php
include("db_connect.php");

if ($con->connect_error) {
    die("Connection failed: " . $con->connect_error);
}

// Get the Reg. No from the request
$vehicle_reg_no = $_GET['vehicle_reg_no'];

// Prepare and execute query
$sql = "SELECT * FROM customer_details WHERE vehicle_reg_no = ?";
$stmt = $con->prepare($sql);
$stmt->bind_param("s", $vehicle_reg_no);
$stmt->execute();
$result = $stmt->get_result();

// Check if record exists
if ($result->num_rows > 0) {
    $data = $result->fetch_assoc();
    echo json_encode($data); // Send data as JSON
} else {
    echo json_encode([]); // Send empty array if no match
}

$stmt->close();
$con->close();
?>
