How to Prevent Injection?

Hello to everyone.The javascripts files in my website are constantly getting injected with malicious codes which redirects my website,can any one please tell me how do i stop such injections?the website is in php.I am a newbie with website programming so really need help with it .:frowning:

This is nothing to do with your actual javascript. If someone is injecting code into your websites, this is happening on the server. You need to find out how they’re doing this, and it probably isn’t related to PHP either, as the code is probably being injected directly into the .js file itself. It’s probably someone gaining access to your server. Perhaps you should contact your hosting provider or post your question in the Server Management forum.

Hi,

I think you are most likely talking about Cross Site Scripting or XSS.
It happens when you serve something on a page that has come directly from the user without proper validation.

An example could be where you are accepting HTML for a blog post, someone could post a redirect script that you are then writing into the page.