Showing content whether user is logged in or not?
-
I need some help with how content changes when a user is logged in and off, (MySQL - phpmyadmin) the code I have right now is this: <?php session_start(); if (isset($_SESSION['members'])) { echo "<div id='top_right'><a href='/profile.php'>Profile</a> | <a href='/members.php'>Members Area</a> | <a href='/settings'>Settings</a> | <a href='/logout.php'>Logout</a><br>"; } else echo "<div id='top_right'><a href='/login.php'>Login</a> | <a href='/register.php'>Register</a><br>"; ?> but for some reason this does not change it just keeps it as Login | Register. the table I inputed the login stuff into is named members and has 6 fields, these being in order: id, username, password, email, date, ip Does anyone have any detail on why this is not working? I can login correctly as when I go to my members.php page it says You are currently logged in, admin. but thats it, the navigation still does not change, any help? Cheers, Liam.
-
Answer:
if isset(($_SESSION['members']) and ($_SESSION['members'] != "")) { // If they are registered and NOT NULL Also... Your ELSE statement is not enclosed in curly braces.. The PHP server is reading echo "<div id='top_right'><a href='/login.php'>Login</a> | <a href='/register.php'>Register</a><br>"; as UNCONDITIONAL.. drop some braces around that bad boy. I am assuming your login process has $_SESSION['members'] = TRUE; someplace?
Liam at Yahoo! Answers Visit the source
Related Q & A:
- How can I make Private Messages in Drupal 7 with user user pictures like in Facebook?Best solution by Drupal Answers
- How to stay logged in for Android?Best solution by Stack Overflow
- How to check on all the permissions granted to a user and apply the same permissions to another user?Best solution by Stack Overflow
- How do I permanently block a user forever? I mean, find or enter the username, when the user isnt on my list?Best solution by Yahoo! Answers
- Why won't my computer keep me logged into sites even when I click stay logged in?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.