Most spicy hot foods such as chili peppers, habaneros and cayenne peppers contain capsaicin, which is not broken down and digested, especially in the seeds, and that is what burns your entire digestive tract from when it first enters your mouth until it leaves.
Capsaicin stimulates the lining of the stomach to produce more of its natural juices to protect itself against the capsaicin. This is actually good, because this process kills the bacteria in the stomach would could cause disorders of your bowels. However, it is painful for people who already have ulcers. (Contrary to the prevailing myths, spicy foods do not cause ulcers. That culprit is a bacteria named Helicobacter pylori. However, spicy foods do make ulcers hurt worse.)
Capsaicin does irritate the linings of the small and large intestines where food goes after leaving the stomach. For many people, especially those who often eat hot spicy foods and who therefore have forced their alimentary canals to adapt to the stress, the irritation is minor and they don’t even notice. But other people, especially those who don’t often eat spicy hot foods, are sensitive to it. The body reacts to the irritation by sending extra water to the intestine to prevent damage to the lining. Also, the irritated intestinal lining moves the food along faster than usual, resulting in diarrhea. There is no medical evidence that eating capsaicin does permanent injury to intestinal linings. The capsaicin continues to irritate sensitive inner tissue all the way through the end, so it continues to burn even as someone is eliminating it.
People who continue to have the problem may be suffering from irritable bowel syndrome. They suffer from loose stool, bloating and abdominal pain when they eat hot foods, plus dairy, caffeine, and fatty and oily foods.
There are many ways to reduce the gastrointestinal discomfort of eating spicy foods. If people drink a glass of water before eating, that will help dilute the juices in the stomach.
Dairy foods help to neutralize the capsaicin. Therefore, drinking milk or eating yogurt, curd, ghee, buttermilk, sour cream or ice cream after eating the hot foods can help prevent diarrhea. However, people who are lactose intolerant should not consume any product containing milk. Consuming coconut milk, which is common in Thai food, can also help neutralize capsaicin. Eating rice gruel or bread along with the hot spice should also alleviate its impact on the digestive system.