<?php
include 'db_connection.php';

$reply_id = isset($_POST['reply_id']) ? intval($_POST['reply_id']) : 0;
$new_reply = isset($_POST['reply']) ? trim($_POST['reply']) : '';

if ($reply_id > 0 && !empty($new_reply)) {
    $sql = "UPDATE message_replies SET reply = ? WHERE reply_id = ?";
    $stmt = $conn->prepare($sql);
    $stmt->bind_param("si", $new_reply, $reply_id);
    if ($stmt->execute()) {
        echo json_encode(['status' => 'success']);
    } else {
        echo json_encode(['status' => 'error', 'message' => 'Failed to update reply']);
    }
    $stmt->close();
} else {
    echo json_encode(['status' => 'error', 'message' => 'Invalid input']);
}

$conn->close();
?>
