Welcome to Geeklog Tuesday, November 12 2019 @ 06:04 am EST

Geeklog Forums

Grabbing Usernames


Status: offline

cmdrkettch

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

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/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 EST. The time is now 06:04 am.

  • 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