首页 运维 网络学院 查看内容

PHP防止XSS攻击

2015-4-23 14:30 2653 0

摘要: mysql_real_escape_string()所以得SQL语句如果有类似这样的写法:"select * from cdr where src =".$userId; 都要改成 $userId=mysql_real_escape_string($userId)所有有打印的语句如echo,print等 在打印前都要 ...
关键词: userId htmlentities 语句 nbsp string escape 印前 mysql 写法 real

mysql_real_escape_string() 

所以得SQL语句如果有类似这样的写法:"select * from cdr where src =".$userId; 都要改成 $userId=mysql_real_escape_string($userId) 

所有有打印的语句如echo,print等 在打印前都要使用htmlentities() 进行过滤,这样可以防止Xss,注意中文要写出htmlentities($name,ENT_NOQUOTES,GB2312) 。 
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋
发表评论

最新评论

返回顶部