The problem may be that there is dirt stuck in the mechanism for your power button, and that’s what preventing the phone from staying on. What I did to get the dirt out was rub a toothbrush really quickly over the power button and after a few tries the phone started working again.