Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.