请问个防注入有关问题

WBOY
Release: 2016-06-13 11:58:33
Original
823 people have browsed it

请教个防注入问题?

<tr><th>姓名:</th><td><?=$this->iff($flag, $myBank['username'],'<input name="username" class="input_text" placeholder="姓名" value="'.$myBank['username'].'" />')?></td>
Copy after login

这里没有限制使用其他字符,有的黑客可以注入代码,有没有好的方法可以让黑客彻底注入不了代码?限制只能输入中文?
------解决方案--------------------
去除html 标签 PHP htmlspecialchars函数  用正则匹配输入
------解决方案--------------------
1)strip_tags(string str); 
2)htmlspecialchars
3)preg_replace("//","",$str);  
------解决方案--------------------
strip_tags
htmlspecialchars
两个函数即可。
------解决方案--------------------
用php函数mysql_real_escape_string 过滤,可以防止注入

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!