If your iPhone or iPad won't charge, one of the first and easiest things to try is a hard reset. Whether it's really shutting down on its own, or it's rapidly depleting the battery due to rogue processes or Wi-Fi or cellular radio activity, a reset can help. Make all the "reboot Windows" jokes you want but sometimes bad bits get stuck and need to be flushed out.
Press and hold down both the Sleep/Wake button and the Home button at the same time.
Keep them held down until you see an Apple logo.
Let go.