How to prevent external malicious submissions from calling the ajax interface in PHP ajax php post jquery ajax php ajax points

WBOY
Release: 2016-07-29 08:53:35
Original
1286 people have browsed it

If we use the ajax interface we wrote on our website for ourselves, we can limit the source domain name and determine the source.

Note: Replacewww.jb51.netwith your own domain name.

Copy the codeThe code is as follows:

//Judge the source
if(!isset($_SERVER['HTTP_REFERER']) || !stripos($_SERVER['HTTP_REFERER'],'www. jb51.net')) {
echo 'cann`t access';
exit();
}

The above introduces how to prevent external malicious submissions from calling the ajax interface in PHP, including the content of ajax and php. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!