I am new to this forum and very new to code in general. I have a code that hides a block of text if a user is not logged into our site:
if( !empty($_SESSION['user'])
what I need is a code that will hide a different block of text if a user IS logged in.
Any help would be appreciated...
PHP Code
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: PHP Code
The opposite of
would be
The exclamation mark indicates "not" or "the opposite of".
Code: Select all
if( !empty($_SESSION['user']))Code: Select all
if( empty($_SESSION['user']))Re: PHP Code
or maybe make more sense (at least for me)
:
Code: Select all
if( !empty($_SESSION['user'])) {
// here the code that hide text block 1.... user logged
} else {
// here the code that hide text block 2.... user not logged
}- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: PHP Code
Yes, that works too... but they're not necessarily in the same place.