How to prevent external malicious submissions from calling the ajax interface in PHP

墨辰丷
Release: 2023-03-29 15:50:01
Original
2527 people have browsed it

This article briefly introduces how to prevent external malicious calls to the ajax interface to save traffic and reduce server pressure.

If we use the ajax interface written by our own website for ourselves, we should limit the source domain name and determine the source.

Note: Replace www.jb51.net with your own domain name.

Copy 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();
}

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

phpDetailed explanation of file upload class examples

phpImplementation Methods and meanings of singleton mode

php html5 ajax methods and examples for uploading images

The above is the detailed content of How to prevent external malicious submissions from calling the ajax interface in PHP. For more information, please follow other related articles on the PHP Chinese website!

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template