Jump to content

Changing navbar if user is logged on or not


Go to solution Solved by requinix,

Recommended Posts

Hi there PHPFreaks, phreak3r is back for the second time today! I have been trying to figure out how to implement a minor change here.

When the user is not logged in, the nav bar will display Register/Login, that has already been accomplished. When the user is logged in, the nav bar should display logout.

I am trying to figure out how to best go about doing that. Suggestions are greatly appreciated, thank you!

<?php if (user is logged in) { ?>
logout stuff
<?php } else { ?>
login stuff
<?php } ?>

 

Yes, I have done that, but at the top of each page I include a header file with Register|Login in the navbar. I want to figure out how to dynamically change it when the user is logged in. The process of checking if the user is logged in or not takes place in another file separate from the header file. What you've provided me above is already in my script.

I assume either you're asking for a way to violate causality, or you're waiting for someone to tell you that you have to rearrange your code.

Ahaha, quite the comedian, I assume so. Well, thank you!? Sorry for taking up valuable space with this thread, feel free to delete it.

Yes, I have done that, but at the top of each page I include a header file with Register|Login in the navbar. I want to figure out how to dynamically change it when the user is logged in. The process of checking if the user is logged in or not takes place in another file separate from the header file. What you've provided me above is already in my script.

 

In this case, simply repeat the same logic in your header file (you can do if logged_in... else... stuff an unlimited number of times in different files)

In this case, simply repeat the same logic in your header file (you can do if logged_in... else... stuff an unlimited number of times in different files)

 

Thanks, but 'tis this is no longer an issue, I've done it dynamically. Thank you for the help though!

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.