Home repairs for an iPhone 5 charging cable present several safety concerns due to the possibility of creating a fire hazard; thus, the best solution is to purchase a new cord entirely. First check that it is in fact the charger that is malfunctioning, and not the charging port on the phone. You may replace the charging port yourself with the proper tools and equipment.
Begin by examining the charging cable for the iPhone 5 to look for any signs of frays, burns or tears that prevent it from properly conveying the current into the phone, along with dents in either the USB or Lightning ports. Most malfunctions result from damage to the wires that conduct the current, which may lead to a fire because the cable is no longer able to properly handle the charge. As such, the safest method is to dispose of the broken cable and purchase a new model rather than attempting a repair that may cause injury or further damage.
If the cable works with other devices, but not the phone, then the charging port on the phone is likely malfunctioning. To replace the port, unscrew the case near the speakers, and use a suction cup to lift off the front cover. Unscrew the battery, and remove it. Then, disconnect the charging port, and replace it with a new model. Secure the battery, and connect it to the new port, then replace the screen and the bottom casing screws.