UTI problems

I went to the ER 2 days ago because I was having back spasms but turns out that I have a UTI I think I gotten it from sex but how would I know? And are there any advice for me? This is so weird to me I never had one before until now and I can’t help but to feel dirty now.