Page 1 of 1

PHP If statement

Posted: Sun Mar 20, 2011 7:46 pm
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

Re: PHP If statement

Posted: Sun Mar 20, 2011 8:43 pm
by miki
u can save the session in a file or table, if the guest have not logged in, the guest name is empty

Re: PHP If statement

Posted: Sun Mar 20, 2011 9:48 pm
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