Bleeding during and after sex

I am 36 weeks pregnant and 1 cm dilated and had sex last night. I have read that spotting after sex is normal and nothing to worry about. But i didn't have just a little spotting, I was full on bleeding. There was blood all over my bf, and me. i went to bathroom to wash it off and blood was dipping down my leg and my bf had to shower because he had so much on him. I ended up just gettinf dressed and put a pad on and had painful contractions and lower back pain but i was able to go to bed. This was around 11 at night last night and now it is 1:00 in the afternoon and still having some bleeding but not as much as before. Its coming out with my discharge and im still having painful contractions. They will go like 8 mins apart then go random then go 4 mins apart and then random again and then 5 mins apart and go random or just stop for a little bit. Any idea on whats going on?