iPhone will suddenly shut down repeatedly unless charged
Solution 1:
From your description of the problem, my best guess is that the battery needs replacing because it can't hold a charge reliably. That may be your next step to resolution. More serious may be damage to the iPhone circuitry itself from charging problems, drops/shocks, moisture incursion. Accurate HW failure diagnosis is difficult remotely. Somebody needs to open it up and find out what's wrong.
Apple has some good information here about iPhone batteries. You can read on this Apple Support page about how to get the battery serviced & recycled. Because the iPhone 5 is well out of warrantee, any 3rd-party iPhone repair should be able to replace the battery.
Good luck!