Is my charger damaging my iphone?

So the other day i left my charger at my friends place and since then i have bought a cheap 10$ charging cord from walmart. I used it to charge my phone (iphone 5s) and every time i plug it in it says something about it not being certified and it may not work reliably. Sometimes it charges it sometimes it doesn't. Anyways I used it to charge my phone for 20 minutes before I went to work. When I got to work it was at 60%. About an hour into my shift i went to check my phone and it was extremely hot and wouldnt turn on. I panicked. I plugged it in using a certified iphone cable from my work and it immediately turned on and showed 6% battery life. Anyways, is there anyway that it damaged my iphones battery? Should i stop using this cord. As well i'm charging it right now and it seems to be charging extremely quickly. Its not plugged into the wall just into my macbook.

Using OEM chargers are the best

While OEM chargers generally work the best (and cost the most, which is why they work the best) I have found that if the cable generally looks good and you are using a generic sync style cable (one with a 30-pin or lighting end and one with a USB end) then the pieces of metal that stabilize the USB side and hold it in the plug may have gotten slightly bent causing the bus contacts to sometimes slip. If you can find something small enough to bend them slightly down so they get a good bite on the plug again thats one thing you can try (Do at your own risk and while the computer is not powered up or with an non-conductive object). If that doesn't help any then it's likely that the wires on the lighting side have loose connections or have even possibly become desoldered off the board. If you know electronics you can usually run an exacto knife around the casing and pop it out and find the problem, if you don't know electronics enough to do that then just save yourself a bunch of hassle and buy a new cord thats OEM.