Home  >  Article  >  Backend Development  >  请问个防注入有关问题

请问个防注入有关问题

WBOY
WBOYOriginal
2016-06-13 11:58:33815browse

请教个防注入问题?

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

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

Statement:
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