Chosen Solution
iPhone 5 has been turning off & on by itself for a couple of weeks, but it could still be turned on with power button on top & was charging & working fine. Now it won’t turn on & when put on charger, the white apple boot up screen turns on then off, in an endless loop.
Sounds like either a dying battery, or just a simple boot loop (caused by corrupted software). I would try to restore the phone first, by putting the phone in DFU mode. If it doesn’t restore, its probably a battery issue or a logic board failure. Overall, its most likely a simple boot loop, and hopefully a restore will resolve it. Good Luck!