How to get a users id from their username or email

Im trying to fetch a users id based off of their username, but I’m not sure how to go about it. What I’m trying to do is, when a user is logging in, and he or she enters their username in the username field, i want to fetch that users id somehow then. Any ideas? is it possible to fetch a users avatar from their email?