Welcome to Geeklog, Anonymous Saturday, July 20 2024 @ 06:18 pm EDT

Geeklog Forums

Grabbing Usernames

Status: offline


Forum User
Registered: 10/09/03
Posts: 5
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?

Status: offline


Site 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

All times are EDT. The time is now 06:18 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