Zola Posted March 9, 2012 Share Posted March 9, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/258591-need-help-getting-a-login-slider-to-disappear-when-logged-in/ Share on other sites More sharing options...
Drongo_III Posted March 9, 2012 Share Posted March 9, 2012 not sure how you render your pages but you could do with a simple conditional and an include. So when they log in you set a session variable to signify they've been authenticated and logged in. Then you can just do something simple like if (!isset($_SESSION['loggedin'])){ include('slide_login_header.php') } else {// either do nothing or include an alternate header] Quote Link to comment https://forums.phpfreaks.com/topic/258591-need-help-getting-a-login-slider-to-disappear-when-logged-in/#findComment-1325548 Share on other sites More sharing options...
Zola Posted March 9, 2012 Author Share Posted March 9, 2012 Awesome thanks! I will give that a go and report back Quote Link to comment https://forums.phpfreaks.com/topic/258591-need-help-getting-a-login-slider-to-disappear-when-logged-in/#findComment-1325657 Share on other sites More sharing options...
Zola Posted March 12, 2012 Author Share Posted March 12, 2012 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 work? <?php if(!isset($_SESSION['name'])) { include ('includes/login_panel.php'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/258591-need-help-getting-a-login-slider-to-disappear-when-logged-in/#findComment-1326301 Share on other sites More sharing options...
Zola Posted March 12, 2012 Author Share Posted March 12, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/258591-need-help-getting-a-login-slider-to-disappear-when-logged-in/#findComment-1326309 Share on other sites More sharing options...
dragon_sa Posted March 12, 2012 Share Posted March 12, 2012 every page you use sessions on, needs to have session_start(); at the top in the php section, or the session variables will not work Quote Link to comment https://forums.phpfreaks.com/topic/258591-need-help-getting-a-login-slider-to-disappear-when-logged-in/#findComment-1326326 Share on other sites More sharing options...
Zola Posted March 12, 2012 Author Share Posted March 12, 2012 That would be a complete noob error on my behalf. Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/258591-need-help-getting-a-login-slider-to-disappear-when-logged-in/#findComment-1326338 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.