Cramping up during and after sex

Does anyone start cramping up during or after sex? Sometimes it feels like he is hitting something up in there and sometimes that causes it. Other times I dunno...maybe where I'm getting close to my period? It really hurts. Any ways to prevent it from happening?