My iphone 4 is hard to charge?

So today my mom got the new galaxy s4 and she gave me her 3 year old iphone 4, i plugged it in to the charger and it didn't charge, then i unplugged it and plugged in again and it still didn't charge, then i plugged it in for the third time and it finally charged, then i put down the iphone and it stopped, then charged, then stopped again, it seem like whenever i move the iphone it stops charging, its driving me crazy, it charges at random times, its pissing me off

Maybe its time to get a new charger or if the iphone is in bad condition that maybe be the problem

Your iPhone Charge Might Be Messed Up Or Get A Old Toothbrush & Clean The Dust Or Lent In The Charger Plug In Area