<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Content-Type");
header("Access-Control-Allow-Methods: POST");

$host = "localhost";
$user = "wanywebc_baski";
$pass = "Adgebs123.";
$db   = "wanywebc_baski";

$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
  echo json_encode(["success" => false, "message" => "Bağlantı hatası"]);
  exit;
}

$data = json_decode(file_get_contents("php://input"), true);
$id = intval($data["id"]);
$durum = $conn->real_escape_string($data["durum"]);

$sql = "UPDATE satici_basvurular SET durum = '$durum' WHERE id = $id";
if ($conn->query($sql)) {
  echo json_encode(["success" => true]);
} else {
  echo json_encode(["success" => false, "message" => $conn->error]);
}

$conn->close();
?>