Ok...so I had a similar problem where the phone was power cycling on its own and even when it was on, it turned itself off and so on.
My first instinct was to get a priest and some holy water, but then the rational side of me returned and I decided to open up the phone. What I did was get to the area where the buttons are located and found that one of the metal caps that pushes back the button up when its depressed had shifted slightly and was making contact with another part of that circuit board that was responsible for turning off the phone.
Once reseated into its correct position, the phone worked like a charm again
Hope this helps