Bleeding after passing stool?

For around 6 weeks now, almost every time I pass a stool, when I wipe there is bright red blood? It is so painful to go to the toilet too.. Has anyone ever had this or have any ideas what it could be? I have had sharp stabbing pains around my hips for a few months too, wonder if this is related?