Home >Backend Development >PHP Tutorial >How to prevent external malicious submissions from calling the ajax interface in PHP ajax php post jquery ajax php ajax points

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 08:53:351364browse

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: Replace www.jb51.net with your own domain name.

Copy the code The 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.

Statement:
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