문제

I am using an AJAX request to retrieve and display data from my database.

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

venuequery-json.php obviously delivers a nice json-formatted version of the data contained in my database to the grid component. The problem is: how can I prevent others from calling the .php file directly and then get a ready-to-use dump of the content of my database (PHP, MySQL) ?

도움이 되었습니까?

해결책

Use the same method you are currently using to secure the page that fetches the data to secure the ajax one (authentication via cookies or session or htaccess or whatever). You obviously trust that method enough to send it in first place.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top