<?php
session_start();
include 'dbconnect.php'; // Make sure $con is defined

if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
    // Invalid request
    header("Location: list_conversations.php");
    exit;
}

$id = intval($_GET['id']);

// Prepare and execute delete query
$stmt = $con->prepare("DELETE FROM client_agent_conversations WHERE id = ?");
$stmt->bind_param("i", $id);

if ($stmt->execute()) {
    // Success — redirect back with success message (optional)
    header("Location: list_conversations.php?msg=deleted");
    exit;
} else {
    // Error handling (optional)
    echo "Error deleting record: " . $con->error;
}
?>
