Try connecting the phone via a USB cable to the USB port of a working laptop/PC.
If the charging connection stays on, you either have a faulty charger or charger cable.
If it behaves as before, most likely you have a loose or faulty charging connector (USB port) in the phone.
Here is a link that shows the dis-assembly of your phone. At 5:35 minutes into the video it shows the start of the removal of the charging port circuit board.
Here is a link that shows the replacement part. It is not meant as a recommendation to use the seller. It is just to show you what it looks like.
Note: It seems as though there is something attached to the middle of the charging port board (square black object) which is seen in the video but is not showing in the replacement part picture. Perhaps it is just a component (or perhaps even a 'spacer' to support the cover at that point) that is 'stuck' there with connections elsewhere rather than being connected to the board itself and would have to be placed back on the replacement board. Looking at a close up of the replacement part picture it seems to be only adhesive tape of some description, without the component on top. Just so that you are aware of this, if you wish to fix it yourself and order the part from somewhere. You may be better able to see what it is, if and when you have the phone open.
Hopefully this is of some help.