Jump to content

Archived

This topic is now archived and is closed to further replies.

CJLeah

Show Currentuser

Recommended Posts

I'm having trouble wit a code, i'm quite sure is wrong, what I want is a code that will show the current user, eg Hello Chris. ANyway whats wrong with mine, or whats right, lol. please help :)

<?php mysql_query("SELECT username FROM users"); echo ($_POST['username']); ?>

Share this post


Link to post
Share on other sites
When your user log on the system, are you saving the ID in a session?

If you are saving, just put the test on select to select the correct user.

=)

Are you saving something or just login ?

D.Soul

Share this post


Link to post
Share on other sites
the session is saved, but it's not straight after login, even though your logged in to see it, its more of like, a paragraph of text then sayng they user name.....but I have no idea to get the users name to appear...:(


eg:

Yo .currentuser. how are you today, please submit the scriptcheck before proceeding..

Share this post


Link to post
Share on other sites
[!--quoteo(post=366152:date=Apr 18 2006, 09:05 PM:name=Chris Leah)--][div class=\'quotetop\']QUOTE(Chris Leah @ Apr 18 2006, 09:05 PM) [snapback]366152[/snapback][/div][div class=\'quotemain\'][!--quotec--]
the session is saved, but it's not straight after login, even though your logged in to see it, its more of like, a paragraph of text then sayng they user name.....but I have no idea to get the users name to appear...:(
eg:

Yo .currentuser. how are you today, please submit the scriptcheck before proceeding..
[/quote]

I was also trying to display the username, i'm using this once, they're logged in, just rip the username strate out of the session variable...


<?php if ($_SESSION['MM_Username'] != NULL) {
?>
Welcome,<?php echo " ".$_SESSION['MM_Username']; ?>

basically, the username is stored in a session variable, so you test to see if they're logged in (as when they're not logged in, the session variable is NULL. If they are logged in, then you display "Welcome <user>".

There is a bit more to the code, which if the user is not logged in, it display's a login form. But hopefully that bit will get it working for you!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.