Home >php教程 >php手册 >很好用的防SQL注入php函数

很好用的防SQL注入php函数

WBOY
WBOYOriginal
2016-06-13 10:38:55830browse

很好用的sql注入函数


        function inject_check($sql_str) {
                return eregi(select|insert|update|delete||/*|*|../|./|union|into|load_file
|outfile, $sql_str);     // 进行过滤
        }
?>

完善上面函数
function inject_check($sql_str) {
   $check=eregi(select|insert|update|delete||/*|*|../|./|union|into|load_file|outfile, $sql_str);     // 进行过滤
   if($check){
       echo "输入非法注入内容!";
       exit();
   }else{
       return $sql_str;
   }

}

PHP内置函数可以用addslashes()实现和上面函数功能。

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