<?php
  require_once("connectDB.php");
  
  if(isset($_GET['action']) && $_GET['action'] == "updateStatus") {
    $qry = "UPDATE data_users set status = IF(status = 0, 1, 0) where id=$_GET[id]";
    $query = mysqli_query($conn, $qry);
    header('Location: usersList.php');
  }

  if(isset($_GET['action']) && $_GET['action'] == "deleteUser") {
    $qry = "DELETE FROM data_users WHERE id=$_GET[id]";
    $query = mysqli_query($conn, $qry);
    header('Location: usersList.php');
  }
  
  $qry = "SELECT * FROM rfid_code";
  $query = mysqli_query($conn, $qry);
  $row = mysqli_fetch_array($query);
  if(!$query) {
    $rfid_code = '';
  } else {
    $rfid_code = $row['rfid_code'];
  }
  echo $rfid_code;
?>