“changeUserRole”操作总是将我带到 localhost... 这是 xampp index.php,而不是 myproject/index.php?setting=userlist。我不明白为什么我在不同的文件中为不同的设置实现了相同的技术。
它应该重定向到的文件是 action_changeuserrole.php,它运行 SQL 查询并重定向回这个文件,只是没有参数。
function showUserlistManagement() {
if (@$_GET['action'] == "addUser") {
require_once('actions/userlist/adduser.php');
}
else if (@$_GET['action'] == "changeUserRole" ) {
require_once('actions/userlist/action_changeuserrole.php');
}
else {
echo "<a href='?setting=userlist&action=addUser'><button>Add User</button></a>";
$i = 0;
$sql = "SELECT doctorID, username, isAdmin FROM doctor ORDER BY isAdmin DESC";
$result = query($sql);
echo "<table border='1'>";
while ($row = mysql_fetch_array($result)) {
$i = $i + 1;
echo "<tr><td>" . $i . "</td><td>" . $row['username'] . "</td><td>" . isAdminText($row['isAdmin']) . "</td><td><a href='?setting=userlist&action=changeUserRole&userID=" . $row['doctorID'] . "&userRole=" . $row['isAdmin'] . "'><button>" . changeUserRoleButton($row['isAdmin']) . "</button></a></td></tr>";
}
}
function isAdminText($isAdmin) {
if ($isAdmin) {
return "admin";
}
else return "user";
}
function changeUserRoleButton($isAdmin) {
if ($isAdmin) {
return 'Demote';
}
else return 'Promote';
}
}
action_changeuserrole.php 文件:
<?php
//$sql = "UPDATE doctor SET (isAdmin = '1') WHERE doctorID = " . $_GET['userID'];
//$result = query($sql);
?>
<meta http-equiv='refresh' content='0; URL=../../index.php?setting=userlist'>