I am trying to use $current_url = basename($_SERVER['PHP_SELF']); to determine which page I am on, given that my navigation (html) is stored in a php file and is included in each page. This is the code I use to determine which navigation function should be active:
<link rel="stylesheet" href="css/style.css"> <link rel="stylesheet" href="css/no-background.css"> <ul> <?php $current_url = basename($_SERVER['PHP_SELF']); $active = "class=\"active\""; ?> <?php if ($current_url == "globaluser.php") { ?> <li <?php echo $active;?> > <?php } ?> <a href="globaluser.php?Agent=<?php echo $Agent;?>">Overview</a></li> <?php if ($current_url == "search.php") { ?> <li <?php echo $active;?> > <?php } ?> <a href="search.php?Agent=<?php echo $Agent?>">Add new client</a></li> <?php if ($current_url == "viewadmins.php") { ?> <li <?php echo $active;?> > <?php } ?> <a href="viewadmins.php?Agent=<?php echo $Agent?>">View admins</a></li> <li class="border-right"><a href="emails.php?Agent=<?php echo $Agent?>">E-mails</a></li> <li class="right border-right"><a href="logout.php"><?php echo $Agent?></a> <ul class="drop1"> <li><a href="earnings.php?Agent=<?php echo $Agent?>">Earnings</a></li> <li id="hover-trigger"><a href="#">Change Password</a> <ul class="drop2"> <li> <form action="changepass.php?Agent=<?php echo $Agent?>" method="POST"> <input type="password" name="1" placeholder="Enter new password"> <input type="password" name="2" placeholder="Repeat new password"> </li> <li> <input type="submit" name="changepw" class="button" value="Change"> </form> </li> </ul> </li> <li> <form action="logout.php"> <input type="submit" class="button" value="Log out"> </form> </li> </ul> </li>
But that will not work. It shows the active page as active, however it shows 2 pages as simple hyperlinks. It looks like this:

Does anyone know why this is happening? It works for 2, but not suitable for 2, but the exact code? Thanks
source share