The history which you are describing is suggestive of hemorrhoids (piles), which is associated with bleeding from the anal opening (butts) during/ after passing stools. The pain you are complaining of can be because of an associated fissure. You are feeling light headed because of the amount of blood you are losing.
You should show yourself to a surgeon immediately and ask him to perform a rectal examination
(can be a bit uncomfortable but is required in your case). This will help him reach a diagnosis and also rule out something scary like a cancer. If it does turn out be hemorrhoids, he will prescribe you some laxatives and tell you to make some changes in your diet (increase roughage). He might even tell you to undergo a session of banding/ sclerotherapy
of the hemorrhoids, which will take care of the bleeding.
Hoe you get well soon. Tc