过滤get提交过来的变量htmlspecialchars就够了吧?
比如要实现搜索用户名的功能,其实用户名是get过来的,用htmlspecialchars就够安全了吧?
PHP code
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->htmlspecialchars(trim($_GET['username']), ENT_QUOTES);
------解决方案--------------------
addslashes 处理(')、(")、(\)与 NULL
------解决方案--------------------
其实你是要防sql注入吧。对于
因此,最安全的还是通过 mysql_real_escape_string() 来转义防止攻击数据库, 可以下面这样写就安全了:
if (get_magic_quotes_gpc()) {
$username= stripslashes($_GET['username']);
}
else {
$username= $_GET['username'];
}
$username= mysql_real_escape_string($username);
...................................
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