<?php
include('shikanisha.kts.php');

$tot_id = isset($_POST['tot_id']) ? intval($_POST['tot_id']) : 0;

if ($tot_id > 0) {
    $query = "DELETE FROM tots WHERE tot_id = ?";
    if ($stmt = $conn->prepare($query)) {
        $stmt->bind_param('i', $tot_id);
        if ($stmt->execute()) {
            $response = ['status' => 'success', 'message' => 'Tot deleted successfully.'];
        } else {
            $response = ['status' => 'error', 'message' => 'Failed to delete tot.'];
        }
        $stmt->close();
    } else {
        $response = ['status' => 'error', 'message' => 'Failed to prepare the SQL query.'];
    }
} else {
    $response = ['status' => 'error', 'message' => 'Invalid tot ID.'];
}

$conn->close();
header('Content-Type: application/json');
echo json_encode($response);
?>
