if your passing hard thick bowels then you're probably constipated drink castor oil
I can't comment about the stomach pain, but the sweating shortly after a bowel movement is most likely due to cardiac ischemia - that is the heart is not getting enough oxygen. The reasons are complex, however lack of oxygen to the heart often results in sudden cold sweats, particularly on the forehead. These come on rapidly. The reason for this is stimulation of the vagus nerve, which runs near the anal sphincter, which drops the heart rate. Many patients die on the toilet because of this. You should keep hydrated and use stool softener.