<?php
//session_start();
require "includes/config.php";

if (!isset($_SESSION['user'])) {
    echo "login_required";
    exit;
}

if (!isset($_POST['id'])) {
    echo "invalid";
    exit;
}

$id = intval($_POST['id']);

// Delete record
mysqli_query($conn, "DELETE FROM petitions WHERE id = $id");

if (mysqli_affected_rows($conn) > 0) {
    echo "success";
} else {
    echo "failed";
}
?>
