How to user data into database when a user inputs answers to a question?

Hi all,
I am having a bunch of questions the user should answer.
I want to get the answer and the user name or ID put in a database.
But I cannot find a way of doing it without asking for their name.
They will be logged in so I’m sure it is the correct user.

Thank you all!