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

include 'confing.php';

$name = $_POST['name'] ?? '';
$email = $_POST['email'] ?? '';
$phone = $_POST['phone'] ?? '';
$pincode = $_POST['pincode'] ?? '';
$city = $_POST['city'] ?? '';

$sql = "INSERT INTO user_details (name, email, phone, pincode, city) VALUES (?, ?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sssss", $name, $email, $phone, $pincode, $city);

if ($stmt->execute()) {
    $last_id = $conn->insert_id;
    echo json_encode(["status" => "success", "id" => $last_id]);
} else {
    echo json_encode(["status" => "error", "message" => "Signup failed"]);
}

?>
