宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应

[PHP]PHP最简单的代码防SQL注入的源代码

2016-10-13 00:16:48 点击量:14 标签: 收藏本文

[PHP]PHP最简单的代码防SQL注入的源代码

  1. Function inject_check($sql_str) {   
  2.     return preg_match('/select|insert|and|or|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile/i', $sql_str);   
  3. }   
  4. if (inject_check($_SERVER['QUERY_STRING'])==1 or inject_check(file_get_contents("php://input"))==1){   
  5.     //echo "cuplayer.com提示:警告 非法访问!";   
  6.     header("Location: Error.php");   
  7.     exit;   
  8. }   

[PHP]PHP最简单的代码防SQL注入的源代码