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
Release: 2016-07-29 08:53:35
Original
1355 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: 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.

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 Issues
angular.js - Angularjs $http ajax issue?
From 1970-01-01 08:00:00
0
0
0
Ajax click submit but no response!
From 1970-01-01 08:00:00
0
0
0
javascript - Questions about ajax asynchronous
From 1970-01-01 08:00:00
0
0
0
javascript - Questions about ajax?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template