Search code examples
javascriptpostcode-injectionaddress-bar

Is it possible to use inject $.post() from address bar?


I have a javascript in which I use $.post() command to post variables to a php file, I have the URL of the php file hardcoded in the same .js file.

I just want to know if it's possible for someone to inject $.post() command from address bar and send invalid data to the PHP file?

if yes, how to prevent or how to detect those invalid data?


Solution

  • Yes, anybody who knows how to code in JavaScript could send an AJAX POST request to your PHP file.

    As for how to detect the invalid data, that depends entirely on what makes the data invalid. You'll simply need to check the POST values against whatever criteria you're expecting valid data to meet, and then ignore any requests that don't meet those criteria.