Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7857593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:05:05+00:00 2026-06-02T21:05:05+00:00

The changeUserRole action always leads me to localhost… which is xampp index.php, instead of

  • 0

The “changeUserRole” action always leads me to localhost… which is xampp index.php, instead of myproject/index.php?setting=userlist.
I don’t understand why as I have implemented the very same technique in a different file for different settings.

The file it is supposed to redirect to is action_changeuserrole.php which runs an SQL query and redirects back to this file, only without the parameters.

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';
}

}

The action_changeuserrole.php file :

<?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'>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T21:05:06+00:00Added an answer on June 2, 2026 at 9:05 pm

    difficult to understand what you are asking and what exactly is happening in your code, but maybe this will help.

    since the path is relative, where it leads you would depend on what the current url is (or base tag value).

    if your url is:

    foo/bar/something/something/test.php

    ../../index.php would then lead to:

    foo/bar/index.php

    on the other hand, if your url is:

    foo/bar/test.php

    ../../index.php would then lead to:

    index.php

    To help mitigate this, some people use the <base> tag in their HTML. This tag lets you specify a base URL that all relative URLs will use to calculate a final path from. Not 100% sure if this works with meta refreshes. You will have to test.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.