Welcome to Geeklog, Anonymous Tuesday, October 15 2024 @ 09:20 pm EDT

Geeklog Forums

Grabbing Usernames


Status: offline

cmdrkettch

Forum User
Newbie
Registered: 10/09/03
Posts: 5
determined
First of all, let me say that I'm sort of new to Geeklog and PHP. But for a project of mine, I need to be able to grab the username of the user browsing a page and display the corresponding user id. For example, if Bob views the page, it would display Bob's uid and if John views the page, it would display John's uid. Kind of like at the top of this page, where it says "Welcome to Geeklog, username" except one step further. How would I approach this? Could anyone provide some sample code?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Simply check the global variable $_USER['uid']. If it is not empty and contains a value > 1 then that is the user id of the current user.

Anonymous users have a user id of 1 ($_USER['uid'] may also be empty for anonymous users).

bye, Dirk
 Quote

All times are EDT. The time is now 09:20 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content