Home > Backend Development > PHP Tutorial > PHP prevents SQL injection code_PHP tutorial

PHP prevents SQL injection code_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:09:45
Original
1048 people have browsed it

php tutorial to prevent sql injection code

*/

function inject_check($sql_str) { //Prevent injection
$check = eregi('select|insert|update|delete|'|/*|*|../|./|union|into|load_file|outfile', $sql_str);
if ($check) {
echo "Enter illegal injection content!";
exit ();
} else {
Return $sql_str;
}
}
function checkurl() { //Check the source
if (preg_replace("/httpstutorial?://([^:/]+).*/i", "1", $_server['http_referer']) !== preg_replace("/([^:] +).*/", "1", $_server['http_host'])) {
Header("location: http://www.zhutiai.com");
exit();
}
}

//Call
checkurl();
$str = $_get['url'];
inject_check($sql_str);//This can be performed when getting parameters

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629720.htmlTechArticlephp tutorial to prevent sql injection code*/ function inject_check($sql_str) { //Prevent injection $check = eregi( 'select|insert|update|delete|'|/*|*|../|./|union|into|load_file|outfile', $sql_st...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template