I think the second most likely source of the problem is a poor contact somewhere, or possibly a faulty power button.
Have you any details about the phone’s history? Any particular usage conditions? Exposure to humidity?
To fix a contact problem the usual approach is to completely disassemble the phone and clean all contacts on all modules and the battery with isopropyl alcohol or high-grade clinical alcohol.
You’ll need this
You’ll find talk about this in the topics already suggested or here
P.S. - don’t forget to let us know which version of OS you are running
Settings > About phone > Build number or just confirm you’re running stock OS and have updated since May.