Painful sex?

Why does my lower stomach hurt when I'm on top? And after for a few days I have period like pains in lower back and stomach. Any ideas why this is?