Need help getting a login slider to disappear when logged in

Hi all,

I have a problem I am not sure how to sort, hopefully someone here can help.

I have a sliding login panel on a website that I am making. Its quite discreet. I have a stripped down version here that you can see:
http://mgdesign.hostultra.com/login_test/login_test.php

On the page I am making, users with a log in enter their details and will be taken to the restricted page. I would like this sliding panel to be on every page when the user is not logged in.

Once they log in from the sliding panel they can still surf around all the main site pages. When they log out the session dies and it reverts to the home page.

However, when they are logged in I would like the sliding login panel to disappear from the top of each page. Is there any way I can do this simply?

Any help or advice would be greatly appreciated.

Well here is how I’d do it. Upon login, set a session variable, and on each page, see if that variable is NOT set, than echo out the slider. Simple as that :).

ryan said rightly… you try to starting an session using session_start(); . using this you can check whether the session is created of not if so then we can hide the login slider out of the header.

///// check the session using user level will be a smart or a better idea…

if(isset($_SESSION[‘user_name’])) {
return 1;
} else { return 0 ;
}

i hope this may help you… :slight_smile:

Thanks for your replies, butter how would i hide it ?

You wouldn’t have it show on the page by default. You would do the if statement to see if the variable isn’t set. IF IT’S NOT SET, then echo it on the page

So pseudo code…

if(!sessionVARisSET){echo}

Notice the ! which makes it “NOT”.

do you have any field like level to measure the user level whether he is a admin or user like that…???

or can you give me the field you have in users table…???

may be it will help me to explain you on how to hide the login panel… its very simple my friend… respond quickly so that you `ll get some quick response…

Hi,

sorry for the late reply, I was away all weekend.

I have code which I think we can tweak to make it work?

At the moment if the user logs in with wrong details PHP will take the user to a dedicated login / register / support page. The code to do this is:

if(!isset($_SESSION['name'])) {
header("Location: http://mylink");
}
?>

If I add this to the index page and tweak it a little could it may work?

<?php if(!isset($_SESSION['name'])) {
include ('includes/login_panel.php');
}
?>

I tried messing around with this, even adding the footer in to see if it was responding, but doesn’t work:


<?php if(!isset($_SESSION['name'])) {
include ('includes/login_panel.php'); 
}


if(isset($_SESSION['name'])) {
include ('includes/footer.php');			   
}

?>


Anyone know why?

Solved!!

I forgot to add session_start(); at the top.

Thanks for the help all!! :slight_smile: