doz22551 2011-08-25 13:15
浏览 243
已采纳

如何在我的功能中防止XSS攻击?

I am creating a function for my $_POST inputs to prevent SQL Injection BEFORE adding the values into database. I use it on login/register and when a user needs to post an article. As far as I know, this does not secure it from XSS.

Should I create a different function when I output data or edit this?

Thank you.

function clean($str) {
    $str = @trim($str);
    if(get_magic_quotes_gpc()) {
        $str = stripslashes($str);
    }
    return mysql_real_escape_string($str);
}
  • 写回答

4条回答 默认 最新

查看更多回答(3条)

报告相同问题?