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

$match_type = trim($_POST['match_type'] ?? '');
$rules = trim($_POST['rules'] ?? '');

if (empty($match_type) || empty($rules)) {
    echo json_encode([
        "status" => false,
        "message" => "match_type and rules required"
    ]);
    exit;
}

$stmt = $conn->prepare("INSERT INTO match_rules (match_type, rules) VALUES (?, ?)");
$stmt->bind_param("ss", $match_type, $rules);

if ($stmt->execute()) {
    echo json_encode([
        "status" => true,
        "message" => "Rule added successfully"
    ]);
} else {
    echo json_encode([
        "status" => false,
        "message" => "Database error"
    ]);
}
?>