Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End php active navigation help needed

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #34033
    Abz
    Participant

    hey.. im having a problem to get the active state styles in my php navigation..

    il show you the full code and hopefully someone will be able to tell me where im going wrong…

    in the index.php i have..

      

    and…

            
    if(isset($_GET["page"]) && $_GET["page"] != "home"){
    if(file_exists($_GET["page"].".php")){
    include($_GET["page"].".php");
    }else{
    include("PageNotFound.php");
    }
    }else{
    include("home.php");
    }
    ?>

    in my css file i have…

    ul#menu {
    list-style: none; float: right; margin:1px 0 0 0;
    }


    ul#menu li {
    margin: 0 0 0 40px; float: left;
    }


    ul#menu li a {
    display: block;
    font-size: 18px; color: #464545;
    text-decoration: none;
    }

    ul#menu li a:hover {
    border-top: 3px solid #00b4ff;
    }

    ul#menu li.current a {
    border-top: 3px solid #00b4ff;
    }

    would really appreciate if someone could help me out.. thanks in advance.

    #85443
    Dreamdealer
    Member

    First of all: never include files based on user input! This is one of the worst PHP security issues you can make. Please use (at least) a switch statement to include the files. Like this:

    
    switch ($_GET) {
    case "services": include('somefilename.php'); break;
    case "portfolio": include('someotherfilename.php'); break;
    default: include('homepageorsomething.php'); break;
    }
    ?>

    Please read more on PHP security on this page: http://www.devshed.com/c/a/PHP/PHP-Security-Mistakes/

    And second you need to set the active state to the LI wich is active at the moment by adding an if-statement to the line. Like this:


    >Services>
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.