<?php
   include('session.php');
   include('connect.php');
   include('logging.php');

// start role specific 
$user_role = $_SESSION['role'];

if ($_SERVER["REQUEST_METHOD"] == "GET") {

  if (isset($_GET['userid'])) {

    if ($_GET['userid'] == 1) {

      echo "Cannot delete super admin..";

    } else {

      $userid = mysqli_real_escape_string($db,$_GET['userid']);

      $sqlDeleteUser = "
      UPDATE users
      SET enabled = 0
      WHERE userid = $userid;";

            if(mysqli_query($db, $sqlDeleteUser)) {

      $userDelete = "User revoked user ";

      logEvent($db,"User Management",$userDelete,$last_id);
      
      header("location: usersmanagement.php?updated=3");

      } else {
         echo "Error: " . mysqli_error($db);
    }

    }

    
    } else {
    echo "User not selected!!!";
   }
 
}

?>