An example of regular filtering in php to prevent sql injection

WBOY
Release: 2016-07-25 09:11:49
Original
2155 people have browsed it
  1. include("config.php");
  2. if($_GET["id"])
  3. {
  4. $_GET["id"]=inject_check($_GET["id"] );
  5. echo $id;
  6. }
  7. function inject_check($sql_str) {

  8. $check= eregi('select|insert|update|delete|'|/* |*|../|./|union|into|load_file
  9. |outfile', $sql_str);
  10. if($check)
  11. {
  12. echo "Illegal character!";
  13. exit();
  14. }else
  15. {
  16. return $sql_str;
  17. }
  18. }
  19. ?>

Copy code

Articles you may be interested in:

PHP security filtering code (provided by 360 with high security factor) PHP filter post, get sensitive data example code php method to filter illegal and special strings php anti-injection code (filter parameters) How to implement filtering IP black and white lists in php Very useful PHP code to prevent SQL injection vulnerability filtering function A piece of php code to filter dangerous html


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!