Jump to content


Photo

Show Currentuser


  • Please log in to reply
3 replies to this topic

#1 CJLeah

CJLeah
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 18 April 2006 - 07:56 PM

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']); ?>

#2 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 18 April 2006 - 08:00 PM

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
(If something is wrong, please tell me. I'm learning this language. Thank you)

#3 CJLeah

CJLeah
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 18 April 2006 - 08:05 PM

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..

#4 Yuzi

Yuzi
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 18 April 2006 - 11:49 PM

[!--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) View Post[/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!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users