I've had my previously-owned iPhone 5 for almost a year now and a few days ago it started to act strange.
First, while charging it says it's 47%. It suddenly shuts down and then it shows that it's only 7%.
A few days later it suddenly shuts down when I tried to take a picture. When I tried to open it, it shows the Apple logo, shuts down, Apple logo again, shuts down again. This cycle continues until eventually my iPhone gives up and the screen turns pitch black.
I tried plugging my charger. It shows me the Apple logo then my lock screen, but when I take out the charger, the screen vanishes once again, doing the ungodly cycle that happened earlier. It only works when the iPhone is charging.
What do I need to do to fix this issue?