How Can I Add A Link With Php Only When A User Is Signed In?

February 28th, 2010 by CTO WebOjO.com website designers Lahore Pakistan Leave a reply »

I’m using php for my use logins and my set up is..user types in information, it is saved in a mysql table, when they login it verifies the info. How can i make it so that i take away the login link with a logout link and add another link so the user can view their profile?

swarovski crystals

Advertisement

4 comments

  1. Aaron R says:

    When your user logs in you should create a session variable such as $_SESSION['loggedin'] = true. This line would be placed after you write the user to the table successfully. If $_SESSION['loggedin'] is null then you know to display the login link else if $_SESSION['loggedin'] == true then you display the logout link. When the user clicks the logout link then you set the $_SESSION['loggedin'] to null.
    Here is the code you would need to use:
    if (!$_SESSION['loggedin'] == true)
    {
    print (”login< …
    }
    else
    {
    print ("
    logou…
    }

  2. Florin G says:

    you check if login session exists then with if ;)

  3. Monali H says:

    programming Advice
    http://programmingtips.info/

  4. dONb says:

    Pssstt……I recomended visit .-*-.CAPITANCINEMA.-*-. com and enjoy full movies online AND READY TO DOWNLOAD IF U PREFER,new releases added everydays..just enter site in English And Join!!