<?php
require "../config/db.php";

$id = $_POST['id'];
$name = $_POST['name'];
$email = $_POST['email'];
$city = $_POST['city'];
$state = $_POST['state'];
$mobile = $_POST['mobile'];
$gender = $_POST['gender'];
$rank = $_POST['rank'];
$company = $_POST['company'];

$stmt = $conn->prepare("
  UPDATE users SET
    name=?, email=?, city=?, state=?,
    mobile=?, gender=?, rank=?, company=?
  WHERE id=?
");

$stmt->bind_param(
  "ssssssssi",
  $name,$email,$city,$state,
  $mobile,$gender,$rank,$company,$id
);

if ($stmt->execute()) {
  echo json_encode(["success"=>true,"message"=>"User updated"]);
} else {
  echo json_encode(["success"=>false,"message"=>"Update failed"]);
}
