PHP If statement

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
paulmozzie
Forum Newbie
Posts: 1
Joined: Sun Mar 20, 2011 7:41 pm

PHP If statement

Post by paulmozzie »

I'm looking for my website to show the username of the customer, once they have logged into the website. And if they haven't then i want it to show 'guest'
I wondered if anyone could help me?
I'm using joomla 1.5. I know that the code below shows the username, once the user has logged in.
But how can i make it say 'Welcome: Guest' or if possible have the whole box disapear, if they have not logged in.

<?php
$user =& JFactory::getUser();
$welcome = 'Welcome: ';
echo $welcome.$user->username;
?>

Using VM1.1.7
Kind Regards
Paul
miki
Forum Newbie
Posts: 7
Joined: Fri Mar 18, 2011 2:32 am

Re: PHP If statement

Post by miki »

u can save the session in a file or table, if the guest have not logged in, the guest name is empty
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: PHP If statement

Post by fugix »

if they register have it send their information to a database using a form. if they have not logged in yet, make an if() function that if the user info isnt in the database, have the php echo out a div that welcomes them. or vice versa
Post Reply