<?php
include('../config/config.php'); // Ensure DB connection is established


if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $id = $_POST['id'];
    $customer_code = $_POST['customer_code'];
    $customer_name = $_POST['customer_name'];
    $address = $_POST['address'];
    $city = $_POST['city'];
    $pincode = $_POST['pincode'];
    $contact_person = $_POST['contact_person'];
    $phone = $_POST['phone'];

    $stmt = $conn->prepare("UPDATE customers SET customer_code=?, customer_name=?, address=?, city=?, pincode=?, contact_person=?, phone=? WHERE id=?");
    $stmt->bind_param("sssssssi", $customer_code, $customer_name, $address, $city, $pincode, $contact_person, $phone, $id);

    if ($stmt->execute()) {
        echo "Customer updated successfully!";
    } else {
        echo "Error: " . $stmt->error;
    }
    $stmt->close();
    $conn->close();
}
?>
