PHP prevents SQL injection code_PHP tutorial

WBOY
Release: 2016-07-13 17:09:45
Original
955 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...
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!