This has happened several times. If I plug it up to the charger, when it reboots it goes back to the 40% or whatever the battery level that was left. Anyone else had this problem? What can be done?
Try a factory restore through iTunes on your computer. After the restore, let the battery drain completely and let the phone charge fully without playing with it.
If that doesn't help, then the battery might need replacing. :/