开发者

PHP and jquery restrict direct access

Is it possible to restrict direct access to PHP file if I use jquery .load function like this one:

$(document).ready(function(){
$("#second").load("testip.php");
});

In this case I want to restrict direct access to file testip.php that will instert data in database.

开发者_运维知识库

Can I do it using some PHP function that will compare visitors IP address and server IP at "testip.php" file or there is some better way to do it?


This could be helpful.

Detecting ajax events on the server


No, you can't. Unfortunately, there are no "indirect" requests in the HTTP protocol. They are all direct. From the client to the server. You can check the header below, but it can be easily faked.
And visitors IP address and server IP at "testip.php" would be always different.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜