如果用户输入未经修改地插入到SQL查询中,则应用程序将变得容易受到SQL注入攻击,就像以下示例中所示:
$unsafe_variable = $_POST['user_input'];
mysql_query("INSERT INTO `table` (`column`) VALUES ('$unsafe_variable')");
这是因为用户可以输入类似于 value'); DROP TABLE table;-- 的内容,查询将变成:
INSERT INTO `table` (`column`) VALUES('value'); DROP TABLE table;--')
如何防止这种情况发生?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号