<?php

require('../lib/dbclass.php');



$id = $_GET['blockid'];

$data1 = findQuery("select * from tbl_transaction where volunteer=$id");

if ($data1) {
    $message = 'Reference exist cannot block';


    $encodedMessage = urlencode($message);



    $url = "user_management.php?message={$encodedMessage}";

    // Redirect to the new URL
    echo "<script>window.location.href='{$url}';</script>";

    return;
}


$block = updateQuery("update tbl_user set status=1 where id=$id");

if ($id) {
    $message = 'Blocked successfully!';



    $encodedMessage = urlencode($message);



    $url = "user_management.php?message={$encodedMessage}";

    // Redirect to the new URL
    echo "<script>window.location.href='{$url}';</script>";
} else {
    $message = 'Something went wrong, please try again.';


    $encodedMessage = urlencode($message);



    $url = "user_management.php?message={$encodedMessage}";

    // Redirect to the new URL
    echo "<script>window.location.href='{$url}';</script>";
}
