首頁  >  文章  >  後端開發  >  php 防止sql注入代码_PHP教程

php 防止sql注入代码_PHP教程

WBOY
WBOY原創
2016-07-13 17:09:45948瀏覽

php教程 防止sql注入代码

*/ 

 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;
  }
 }
 function checkurl() { //检查来路
  if (preg_replace("/https教程?://([^:/]+).*/i", "1", $_server['http_referer']) !== preg_replace("/([^:]+).*/", "1", $_server['http_host'])) {
   header("location: http://www.zhutiai.com");
   exit();
  }
 }

//调用
checkurl();
$str = $_get['url'];
inject_check($sql_str);//这条可以在获取参数时执行操作

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/629720.htmlTechArticlephp教程 防止sql注入代码 */ function inject_check($sql_str) { //防止注入 $check = eregi('select|insert|update|delete|'|/*|*|../|./|union|into|load_file|outfile', $sql_st...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn