Dirt and debris in your phone's charger port or a faulty component are the most likely causes of intermittent charging problems on your cell phone. Wiggling the charger or power cord around in an effort to get the phone to charge could cause more damage to a loose or faulty connector so fix the problem as soon as possible.
If your mobile phone stops charging when you move the charger's connector, the issue is normally with the device's charging port. Visually inspect the port and look for any dirt, dust or lint build-up on the metal charging contacts. Cleaning the charging port with a clean, dry toothbrush or a microfiber cloth might solve the problem.
Before you attempt any repairs on the phone, you should check that the problem isn't with the charger. If possible, use a spare charger to see if the issue goes away. If you don't have a spare charger, all you can do is inspect the connector for any signs of damage. If you do find signs of damage, your best bet is to get the charger replaced before attempting to repair the phone.
Charging Port Failure
On almost all mobile phones the charging port is connected to the control board by two different methods. The metal contacts in the charging port are lightly soldered to small metal pads on the control board. These connections allow electricity to flow into the control board, but they are fairly fragile. If your phone stops charging when you move the charger, the connections might be insecure or broken. The second way that the charging port is secured to the control board is with solder joints. These joints don't carry any electricity, as their only job is to stabilize the port. If your charging port is loose, which will cause it to stop charging when you move the connector, it is because these joints have failed.
Opening up the phone and attempting to resolder any broken joints is one option. If you don't have the skills or tools to repair your device, or if you don't want to risk voiding your warranty by opening up your phone, you can always attempt to get a warranty replacement. Whether or not your wireless carrier will honor the warranty will generally depend on whether or not it thinks you damaged the device. These solder joints can fail on their own so issues like a loose charging port are generally covered, however, if your device looks abused your wireless carrier may declare the warranty void. If you have insurance you can always go through the insurance company to get a replacement device, or you can simply purchase a new phone.