Press and hold the sleep/wake button, and slide to turn your phone off. Press and hold the same button, and turn it back on. Try to charge your device again.
If restart did not help, again, turn off your phone, connect it to a wall charger, and leave it that way for a while, because it may charge normally.
You will need an adequate tool, such as a toothpick, or a small needle. Use the tool to remove dust and dirt from the charging port, but make sure to do it carefully and gently, to avoid any damage.
If one charging option does not work, for example charging via USB, connect your device to a wall charger. If you tried wall charger, switch to USB.
Is there a new iOS version available? If there is, make sure to get it. When you upgrade your device, the issue will probably be gone.