#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    1
    Rep Power
    0

    How to render different button base on condition?


    Dear all.

    I have a question is how to create a button base on status. let say if not login, the button will direct to the login page, if not, the button will direct to the logout page. May i know how to do this in php? I hv the codes as below..

    $LoginStatus = False;

    session_start();
    if(isset($_SESSION['LoginName']))
    {
    $LoginStatus = True;
    }
    else
    {
    $loginname = "Guest";

    }

    Please advise..
    Thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,332
    Rep Power
    594
    Please enclose your code in [ PHP ] tags. See the sticky at the top of this forum that says READ THIS BEFORE POSTING.

    What have you tried and what is not working the way you want?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,846
    Rep Power
    6351
    You shouldn't be relying on button values for logged in/out status. Any page which requires a login should check to see if the current user is logged in. If they're not, that page should redirect to a login page.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo