Welcome to Geeklog, Anonymous Sunday, December 22 2024 @ 11:07 am EST

Geeklog Forums

How to get user id from user name ?


Bollick

Anonymous
For example :

if($username="john"){$uid=9;}
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
The current user's uid is always available in the global $_USER array: $_USER['uid']. It may be unset (instead of 1) for the anonymous user, though, so make sure to check that.

Otherwise:
Text Formatted Code
$uid = DB_getItem ($_TABLES['users'], 'uid', "username = '$username'");
 

Be sure to sanitize your $username variable before you do that and call addslashes() on it.

bye, Dirk
 Quote

All times are EST. The time is now 11:07 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