gpt4 book ai didi

php - 如何防止通过地址栏进行sql注入(inject)

转载 作者:行者123 更新时间:2023-11-29 14:56:00 25 4
gpt4 key购买 nike

这不起作用,

<?php 
if(!isset($_GET['id'])){
header('location: index.php');
}
$id = $_GET['id'];
if(!is_int($id)){
header('location: index.php');
}


?>

尽管网址是http://localhost/JMToday/classes/images.php?id=53,但它总是重定向我

最佳答案

另一点是使用PDOPrepared Statements 。您可以使用 PDO 获得一定程度的数据库抽象,并且准备好的语句不再需要使用 mysql_real_escape_string 或类似的东西。

另一个解决方案是 ORM,这可能是一个很大的杀伤力,他们很可能会在幕后使用 PDO,但如果需求匹配它,为什么不......

关于php - 如何防止通过地址栏进行sql注入(inject),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4633195/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com