query("SELECT id, userrole, username, enabled FROM app_users WHERE userrole = 'superadmin' AND BINARY username = '$username' AND enabled = 1"); $queryres = $selectid->fetch_array(); $userID = $queryres[0]; // Remove the row(s) corresponding to the specified superadmin from the 'external_users' table $removequery = $mysqli->prepare("DELETE FROM external_users WHERE userid=?"); $removequery->bind_param("i", $userID); if ($removequery->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'failure'; } $removequery->close(); // Remove the password files directory if (is_dir("restr/".$username."/externalext")) { $removedir = exec("rm -rf restr/".$username."/externalext"); } $response = array('result' => $messagetosend); echo json_encode($response); } else { header("Location: roundpin-login.php"); } ?>