Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Second Navigation Bar Problems

Options
  • 02-05-2012 12:30pm
    #1
    Registered Users Posts: 108 ✭✭


    I have built a site with php html and css and I have one small problem that I can't seem to figure out...

    I have a login section and that redirects the user to a profile page where a second navigation bar pops up. The problem is if the user clicks on any of the tabs in the first navigation bar and is sent to one of those pages the second navigation bar disappears. Is there any code that I can use or anyway of being able to keep the second navigation bar showing once the user has logged in....

    Thanks, any help is much appreciated!!

    The html code for the nav bar on the profile page and homepage are as follows:

    Homepage:

    [HTML] <div id="navigation">
    <ul>
    <li><a href="pages/login.php">Log In</a></li>
    <li><a href="pages/contact.php">Contact Us</a></li>
    <li><a href="pages/faq.php">FAQ</a></li>
    <li><a href="pages/register.php">Register</a></li>
    </ul>
    </div> [/HTML]

    Profile Page:

    [HTML] <div id="navigation">
    <ul>
    <li><a href="login.php">Log In</a></li>
    <li><a href="contact.php">Contact Us</a></li>
    <li><a href="faq.php">FAQ</a></li>
    <li><a href="register.php">Register</a></li>
    </ul>
    </div>
    <div id="navigation2">
    <ul>
    <li><a href="logout.php">Log Out</a></li>
    <li><a href="results.php">Results</a></li>
    <li><a href="take_test.php">Take Test</a></li>
    <li><a href="create_test.php">Create Test</a></li>
    <li><a href="profile.php">Profile</a></li>
    </ul>
    </div> [/HTML]


Comments

  • Registered Users Posts: 10,611 ✭✭✭✭28064212


    Have the 2nd navigation bar on all the pages, but only render it if the user is logged in

    Boardsie Enhancement Suite - a browser extension to make using Boards on desktop a better experience (includes full-width display, keyboard shortcuts, dark mode, and more). Now available through your browser's extension store.

    Firefox: https://addons.mozilla.org/addon/boardsie-enhancement-suite/

    Chrome/Edge/Opera: https://chromewebstore.google.com/detail/boardsie-enhancement-suit/bbgnmnfagihoohjkofdnofcfmkpdmmce



  • Registered Users Posts: 108 ✭✭HotP0pp3r


    How would I got about doing that??


  • Registered Users Posts: 10,611 ✭✭✭✭28064212


    How are you handling login sessions at the moment?

    Boardsie Enhancement Suite - a browser extension to make using Boards on desktop a better experience (includes full-width display, keyboard shortcuts, dark mode, and more). Now available through your browser's extension store.

    Firefox: https://addons.mozilla.org/addon/boardsie-enhancement-suite/

    Chrome/Edge/Opera: https://chromewebstore.google.com/detail/boardsie-enhancement-suit/bbgnmnfagihoohjkofdnofcfmkpdmmce



  • Registered Users Posts: 108 ✭✭HotP0pp3r


    At the moment the login sessions are done with php. It drags the user info from the database which is setup using xampp and phpmyadmin

    Php code for login:

    [PHP]
    <?php
    if(!empty($_SESSION) && !empty($_SESSION))
    {
    ?>

    <ul>
    <li><a href="logout.php">Logout.</a></li>
    </ul>

    <?php
    }
    elseif(!empty($_POST) && !empty($_POST))
    {
    $username = mysql_real_escape_string($_POST);
    $password = md5(mysql_real_escape_string($_POST));

    $checklogin = mysql_query("SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'");

    if(mysql_num_rows($checklogin) == 1)
    {
    $row = mysql_fetch_array($checklogin);
    $email = $row;

    $_SESSION = $username;
    $_SESSION = $email;
    $_SESSION = 1;

    echo "<h1>Success</h1>";
    echo "<p>We are now redirecting you to the member area.</p>";
    echo "<meta http-equiv='refresh' content='=2;profile.php' />";
    }
    else
    {
    echo "<h1>Error</h1>";
    echo "<p>Sorry, your account could not be found. Please <a href=\"login.php\">click here to try again</a>.</p>";
    }
    }
    else
    {
    ?>

    <h1>Member Login</h1>

    <p>Thanks for visiting! Please either login below, or <a href="register.php">click here to register</a>.</p>

    <form method="post" action="login.php" name="loginform" id="loginform">
    <fieldset>
    <label for="username">Username:</label><input type="text" name="username" id="username" /><br />
    <label for="password">Password:</label><input type="password" name="password" id="password" /><br />
    <input type="submit" name="login" id="login" value="Login" />
    </fieldset>
    </form>

    <?php
    }
    ?>[/PHP]


  • Registered Users Posts: 10,611 ✭✭✭✭28064212


    So on each of the pages, something like:
    [PHP]<?php
    if(!empty($_SESSION) && !empty($_SESSION))
    {
    ?>

    <div id="navigation2">
    <ul>
    <li><a href="logout.php">Log Out</a></li>
    <li><a href="results.php">Results</a></li>
    <li><a href="take_test.php">Take Test</a></li>
    <li><a href="create_test.php">Create Test</a></li>
    <li><a href="profile.php">Profile</a></li>
    </ul>
    </div>

    <?php
    }[/PHP]

    Boardsie Enhancement Suite - a browser extension to make using Boards on desktop a better experience (includes full-width display, keyboard shortcuts, dark mode, and more). Now available through your browser's extension store.

    Firefox: https://addons.mozilla.org/addon/boardsie-enhancement-suite/

    Chrome/Edge/Opera: https://chromewebstore.google.com/detail/boardsie-enhancement-suit/bbgnmnfagihoohjkofdnofcfmkpdmmce



  • Advertisement
Advertisement