<?php
include 'db.php';

$id = intval($_POST['id'] ?? 0);
$value = ($_POST['value'] ?? '') === '1' ? '1' : ($_POST['value'] ?? '');

if ($id > 0) {
    $stmt = $conn->prepare("UPDATE settings SET value = ? WHERE id = ?");
    $stmt->bind_param("si", $value, $id);
    $stmt->execute();

    echo "success";
} else {
    http_response_code(400);
    echo "invalid";
}
