Jump to content

PHP Dynamic Menu - HELP


mnielsen

Recommended Posts

Hi, I'm trying to create a menu for my site to change when the user is logged in or logged out.

 

<?php if(isset($_SESSION['id']) && isset($_SESSION['sessionID'])){
echo "<a href=\"/profile.php?id=";?><?php echo $_SESSION['id'];?><?php "\">Profile</a> <a href=\"/account.php\">Account</a> <a href=\"/logout.php\">Logout</a>";
else{
echo "<a href=\"/index.php\">Home</a> <a href=\"/signUp.php\">Sign Up</a> <a href=\"/index.php\">Login</a>";
}
?>

 

I've done it before but for the life of me I can't remember it. I need to break the php script so it just includes it as normal text then in my php page then start the script again.

 

What my main objective is to have the profile link with the user id, e.g. /profile.php?id=000000001.

 

Any help PLEASE!

Link to comment
https://forums.phpfreaks.com/topic/113028-php-dynamic-menu-help/
Share on other sites

<?php 

if(isset($_SESSION['id']) && isset($_SESSION['sessionID'])){
   echo "<a href='/profile.php?id={$_SESSION['id']}'>Profile</a><a href='/account.php'>Account</a> <a href='/logout.php'>Logout</a>";
} else {
   echo "<a href='/index.php'>Home</a> <a href='/signUp.php'>Sign Up</a> <a href='/index.php'>Login</a>";
}
?>

<?php if(isset($_SESSION['id']) && isset($_SESSION['sessionID'])){ ?>

<a href="profile.php?id=<?php echo $_SESSION['id']; ?>">Profile</a>
<a href="account.php">Account</a> <a href="logout.php">Logout</a>

<?php
} else { ?>
<a href="index.php">Home</a>
   <a href="signUp.php">Sign Up</a>
   <a href="index.php">Login</a>
   
<?php } ?>

 

Is this what what you mean?

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.