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:
$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