SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict Zapppa's Avatar
    Join Date
    Aug 2009
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  2. #2
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,623
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    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 .
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  3. #3
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RyanReese View Post
    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...

  4. #4
    SitePoint Addict Zapppa's Avatar
    Join Date
    Aug 2009
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your replies, butter how would i hide it ?

  5. #5
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,623
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    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".
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  6. #6
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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...

  7. #7
    SitePoint Addict Zapppa's Avatar
    Join Date
    Aug 2009
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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:

    Code:
    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?

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

  8. #8
    SitePoint Addict Zapppa's Avatar
    Join Date
    Aug 2009
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried messing around with this, even adding the footer in to see if it was responding, but doesn't work:


    Code:
    <?php if(!isset($_SESSION['name'])) {
    include ('includes/login_panel.php'); 
    }
    
    
    if(isset($_SESSION['name'])) {
    include ('includes/footer.php');			   
    }
    
    ?>
    Anyone know why?

  9. #9
    SitePoint Addict Zapppa's Avatar
    Join Date
    Aug 2009
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solved!!

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

    Thanks for the help all!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •