<?php
// Include the database connection file
require_once 'connection.php';
header('Content-Type: text/plain');

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

    // Prepare the delete query
    $delete_sql = "DELETE FROM `blockedtable` 
                   WHERE `blockedBy`='$blocked_by' AND `userBlocked`='$user_blocked'";

    // Attempt delete query execution
    if ($conn->query($delete_sql) === TRUE) {
        if ($conn->affected_rows > 0) {
            echo "User unblock successful.";
        } else {
            echo "No record found to delete.";
        }
    } else {
        echo "Error: " . $delete_sql . "<br>" . $conn->error;
    }
}

$conn->close();
?>
