Jump to content

Recommended Posts

OK I am sure this is straight forward but I am struggling to find a solution.

I have a php script that is called from an ajax request.  I want to make sure that this script can only be called by that ajax request and NOT by someone reading the url and either putting it in the address bar or worse using some kind of bot to call this script automatically.

So basically the php script HAS to check that the call for it to run was from the ajax request and NOWHERE else.
Link to comment
https://forums.phpfreaks.com/topic/28677-calling-a-script-from-ajax/
Share on other sites

Well... the only way to do that is to pass something in the JS... but we all know that anyone can read the JS file, so you're best off including that file within your "backend.php" file or whatever the JS calls.  And you'd be better off grabbing something from a session that you put there and then verifying that in the backend call before running your special little script.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.