PHP链接参数将我引导到localhost/xampp,而不是运行它应该运行的脚本
changeUserRole操作总是将我引导到localhost。。。这是xampp index.php,而不是myproject/index.php?setting=userlist。 我不明白为什么,因为我在不同的文件中为不同的设置实现了相同的技术 它应该重定向到的文件是action_changeuserrole.php,它运行SQL查询并重定向回该文件,但没有参数PHP链接参数将我引导到localhost/xampp,而不是运行它应该运行的脚本,php,html,Php,Html,changeUserRole操作总是将我引导到localhost。。。这是xampp index.php,而不是myproject/index.php?setting=userlist。 我不明白为什么,因为我在不同的文件中为不同的设置实现了相同的技术 它应该重定向到的文件是action_changeuserrole.php,它运行SQL查询并重定向回该文件,但没有参数 function showUserlistManagement() { if (@$_GET['action'] ==
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'>
很难理解您在问什么以及代码中到底发生了什么,但这可能会有所帮助 因为路径是相对的,所以它指向哪里取决于当前url是什么或基本标记值 如果您的url为: foo/bar/something/something/test.php ../../index.php将导致: foo/bar/index.php 另一方面,如果您的url为: foo/bar/test.php ../../index.php将导致: index.php
为了缓解这种情况,有些人在HTML中使用标签。此标记允许您指定一个基本URL,所有相对URL将使用该URL计算最终路径。无法100%确定这是否适用于元刷新。您必须进行测试。您确定您的上级目录链接“../../”确实会引导您找到myproject文件夹吗?是的,我在其他文件夹中有许多文件,但与使用此重定向的级别相同。这似乎只是这个文件中的一个问题。为什么要使用元刷新而不是头重定向?头的位置:http://www.yoursite.com/new_page.html' ;@dqhendricks相对路径是否适用于此?