query('SELECT * FROM users'); while ($line = $DatabaseQuery->fetchArray()) { if ($line['usertype'] == 2 && $line['username'] == htmlspecialchars($_SESSION['username']) && htmlspecialchars($_SESSION['username']) != "" && $line['password'] == htmlspecialchars($_SESSION['password']) && htmlspecialchars($_SESSION['password']) != "") { $AuthorizedRemoval = 1; $AdminIsPrimary = $line['primaryadmin']; break; } } // not authorized if ($AuthorizedRemoval != 1) { header('Location: /'); die(); } $DatabaseQuery = $Database->query('SELECT * FROM users'); while ($line = $DatabaseQuery->fetchArray()) { if ($line['id'] == $id && $line['id'] != "" && $id != "" && $Removed != 1 && $line['primaryadmin'] != 1) { if ($AuthorizedRemoval == 1 && (($AdminIsPrimary == 1 && $line['id'] == 2) || $line['id'] != 2)) { $Database->exec("DELETE FROM users WHERE id='$id'"); $Removed = 1; } else { print "You aren't authorized to perform this action."; die(); } break; } } if ($Redirect == "admin") { header("Location: admin.php?action=users"); } else { header("Location: /"); } ?>