php防注入

服务器:

设置magic_quotes_gpc()为on,display_errors设置为off

传过来的数据

如果是id型,可以用intval()转化成整数类型

如果是字符型,可以用addslashes()过滤一下,然后过滤"_"和"%"

$str = addslashes($str);

$str = str_replace("_", "\_", $str);

$str = str_replace("%", "\%", $str);

密码采取md5加密也可以防止注入

posted @ 2016-10-12 11:18  hell0x  阅读(105)  评论(0编辑  收藏  举报