Jump to content

[SOLVED] Site Navigation with PHP


Trium918

Recommended Posts

I have an if/else statement, and a session that is either TRUE or FALSE.

 

If the session is TURE that means the person is logged in, if it is FALSE it means they are not logged in.

 

session_start();
if($_SESSION['isLogged']){
     // Place the Navigation if the user is logged in
}else{
     // Place the Navigation if the user is not logged in
}

 

I would place this in its own file, then include it on all the pages.

My site employs navigation (carefully) based on the URL vars and my index file acts as a quasi-controller including requested pages. Originally, I stored my navigation info (i.e. heirarchy, visibility) in a table so my boss could control the page order and such. I have since abandoned that and created navigation file defining guest nav, as well as logged in nav for 3 different user types. The user access is determined by a session var pulled from the database upon log in. All protected pages start with a function call checking for the right credentials as defined in a security file included on each protected page.

I have an if/else statement, and a session that is either TRUE or FALSE.

 

If the session is TURE that means the person is logged in, if it is FALSE it means they are not logged in.

 

session_start();
if($_SESSION['isLogged']){
     // Place the Navigation if the user is logged in
}else{
     // Place the Navigation if the user is not logged in
}

 

I would place this in its own file, then include it on all the pages.

 

Ok, inside the code block are you using include() files

with different <u><li><a href="index.php">Home</a></li></u>

Somethting like this:

<?php
session_start();
if($_SESSION['isLogged']){
     echo'<a href="index.php">Home</a>
     <a href="myPage.php">My Page</a>';
}else{
     echo'<a href="index.php">Home</a>
     <a href="login.php">Log In</a>
     <a href="register.php">Register</a>';
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.