<?php
include "dbconnect.php"; // your DB connection

if(isset($_POST['customer_id'])){
    $cid = mysqli_real_escape_string($conn, $_POST['customer_id']);
    $query = mysqli_query($conn, "SELECT * FROM mcust WHERE hpl='$cid' LIMIT 1");
    
    if(mysqli_num_rows($query) > 0){
        $row = mysqli_fetch_assoc($query);
        echo json_encode([
            "status" => "success",
            "name" => $row['name'],
            "pno" => $row['pno'],
            "fname" => $row['fname'],
            "pnoresi1" => $row['pnoresi1'],
            "address" => $row['address'],
            "address1" => $row['address1'],
            "address2" => $row['address2'],
            "houserent" => $row['houserent'],
            "rdate" => $row['rdate'],
            "area" => $row['area'],
            "gg1" => $row['gg1'],
            "g2" => $row['g2'],
            "lmark" => $row['lmark']
        ]);
    } else {
        echo json_encode(["status"=>"error"]);
    }
}
?>
