Answer the question
In order to leave comments, you need to log in
How to allow only Ajax to respond?
There is a site.com/response.php page that receives get requests from ajax
Question: how to prevent it from responding to any other get requests except my ajax because you can put site.com/response.php?id=xx and make a request directly.
I looked at $_SERVER, but it's not clear which of the available parameters is the best way to filter requests...
Answer the question
In order to leave comments, you need to log in
Option 1. Forming a unique key on the page from which the ajax request comes, and checking it in the ajax script.
Option 2: Checking if this particular user visited that page just before the request was sent. It is possible that you just need to make sure that the user is authorized to weed out robots.
And what came into the script without the participation of the server can always be faked.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question