Welcome to Android Central! Which phone? If it's a common phone, then I agree with belodion--any cellphone repair shop should be able to replace the charging port. Before you do that, though, make sure that the port isn't clogged with debris (like lint).
I use a Samsung S6 edge plus and all of a sudden the charging port on the phone wasn't holding the charging cable snugly and the cable was very loose and i started facing issues with charging Found a simple solution that worked great. Took a safety pin and cleaned the charging port on the phone carefully without moving the internal part. I could see a lot of lint and dust accumulated in the socket due to the phone pushed into the pockets. Once cleaned, it is back to working perfectly.