If your iPhone isn't charging properly, try connecting it to different power sources. Connect the USB cable to a wall adapter and power outlet securely. You can also charge your phone from another computer port or using a portable battery. Sometimes, a simple restart is all your iPhone needs to fix any software issues and get your iPhone working again.
Remember, if the charging port is still having problems or you're not sure if you're going to follow these steps, it's recommended that you seek professional assistance from Apple Support or go to an authorized service center to repair the iPhone's charging port. The iPhone charging port does not work due to a lock, preventing a stable connection between the cable and the iPhone. The less common charging problems are because the iPhone is physically damaged, has an old battery that doesn't hold a charge, and uses incompatible iPhone accessories. If your iPhone still doesn't charge or doesn't respond to a forced restart, go to an Apple Store, an Apple-authorized service provider, or contact Apple Support.
If you've followed all the steps described above and you're still unable to charge your iPhone, there's a good chance that the battery is faulty or that your iPhone is damaged.