If cleaning the charging port does not resolve the issue, try a Forced Restart. Hold down the Home and Wake/Sleep buttons at the same time for about 15-20 seconds until the Apple logo appears. You will not lose anything.
If a forced restart does not help try a System Restore. First backup your device using iTunes. Also import your photos to your computer and copy all important data. Try restoring from backup first and testing it. If it does not help, you may have to restore as New and reconfigure from scratch as the backup could be corrupted. For this reason it is important to have your photos and data saved separately from the backup. Here are the steps for a Restore:
https://support.apple.com/en-us/HT201252
If the above steps do not help, you may have to have it tested at an Apple Store.