<?php
// Include the database connection file
require_once 'connection.php';

// Check if form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Escape user inputs for security (assuming connection is established)
    $user_email = $conn->real_escape_string($_POST['user_email']);
    $friend_email = $conn->real_escape_string($_POST['friend_email']);

    // Attempt delete query execution
    $delete_sql = "DELETE FROM `mutefriendstable` WHERE `userEmail` = '$user_email' AND `friendEmail` = '$friend_email'";

    if ($conn->query($delete_sql) === TRUE) {
        if ($conn->affected_rows > 0) {
            echo "Friend unmuted successfully.";
        } else {
            echo "No matching record found to delete.";
        }
    } else {
        echo "Error: " . $delete_sql . "<br>" . $conn->error;
    }
}

$conn->close();
?>
