<?php
include 'db_connection.php';

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

if ($message_id > 0) {
    $sql = "DELETE FROM group_messages WHERE message_id = ?";
    $stmt = $conn->prepare($sql);
    $stmt->bind_param("i", $message_id);
    if ($stmt->execute()) {
        echo json_encode(['status' => 'success']);
    } else {
        echo json_encode(['status' => 'error', 'message' => 'Failed to delete message']);
    }
    $stmt->close();
} else {
    echo json_encode(['status' => 'error', 'message' => 'Invalid input']);
}

$conn->close();
?>
