0

我正在使用 AJAX 请求从我的数据库中检索和显示数据。

$("#flexitopicresults").flexigrid(
{
    url: 'venuequery-json.php',
    dataType: 'json',
    colModel : [ (..)
    (..)
}

场地查询 json.php 显然将我数据库中包含的数据的一个很好的 json 格式版本提供给网格组件。问题是:如何防止其他人直接调用 .php 文件,然后获取我的数据库(PHP、MySQL)内容的即用型转储?

4

2 回答 2

1

使用您当前使用的相同方法来保护获取数据以保护 ajax 的页面(通过 cookie 或 session 或 htaccess 或其他方式进行身份验证)。您显然足够信任该方法以首先发送它。

于 2012-03-21T07:17:59.963 回答
0

You can initialize a session variable in ajax requesting page and then check it in 'venuequery-json.php'. After the checking process, you can renew the session variable. So users must request the ajax requesting page first. Furthermore, you can limit request per time for 'venuequery-json.php' by using sessions again.

于 2012-03-21T07:22:28.300 回答