Home > php教程 > php手册 > PHP的数据过滤防注入的方法.

PHP的数据过滤防注入的方法.

WBOY
Release: 2016-06-21 08:57:25
Original
1174 people have browsed it

PH编程中,处理提交数据并过滤非法字符防注入的方法.

插入数据时用addslashes()就好了,其他的再根据需要进行处理。

不管magic_quotes_gpc是On还是Off,添加数据时都用addslashes(),当On时,必须使用stripslashes(),Off时则不能用stripslashes()。

//提交数据,或者变量准备:
$Content=addslashes("这里面是数据,不管有没单引号或者还是变量");
//插入数据到数据库,代码省略

//开始显示数据
$Content="从数据库读取的数据";
if(get_magic_quotes_gpc()){ $Content=stripslashes($Content); }



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