Display User Login after user has logged in.

burner35

New Member
Messages
127
Reaction score
0
Points
0
Hello all,

I am looking for the php code to display the user login after:
> User has joined
> user has logged out
Example:
> Welcome example to example!

And:
To display this when the user is a guest
> Welcome Guest to Example!

I have been unsuccessful of my Yahoo, Google searches

Cheers,
burner35
 

burner35

New Member
Messages
127
Reaction score
0
Points
0
But is there any other info like select table name, DB info and so on?
 

Salvatos

Member
Prime Account
Messages
562
Reaction score
1
Points
18
I think the easiest way would be to set a session variable. When you validate the user's logging in, you most likely make a query to your DB to check if the login and password match. If they do, you can do something like this:

Code:
(If the user has logged in succesfully)
$_SESSION[logged_in] = TRUE;
$_SESSION[user_login] = [I](either your $_POST[login] or your result from the database)[/I];

Then on any page (as long as you start it with session_start() of course), you can echo something like this:

Code:
if ($_SESSION[logged_in] == TRUE) {
echo 'Hello '.$_SESSION[user_login].', welcome to my website.';
}
else {
echo 'Hello guest, welcome to my website. Why not sign up for free?';
}


P.S. When I say it may be the easiest way, that's according to my limited PHP/SQL skills. I've been using something similar and it works perfectly. Hope that helps anyway.
 
Last edited:
Top