gpt4 book ai didi

php - 如何将我的 SQL 语句更改为准备好的(和安全的)语句?

转载 作者:行者123 更新时间:2023-11-29 07:23:40 25 4
gpt4 key购买 nike

<分区>

基本上我想保护自己免受 SQL 注入(inject)。我曾尝试在线搜索和观看视频,但无法准确理解我必须更改的内容,因为据我所知,每个人的做法都有点不同。感谢您的帮助!

?php
// Create connection
$con = mysqli_connect("IPAddress","User","Password","DBName");
// Check connection
if ($con->connect_error) {
die("Connection failed: " . $con->connect_error);
}

$sql = "INSERT INTO Email_Subs (email)
VALUES ('$_POST[email]')";

if ($con->query($sql) === TRUE) {
echo "You have successfully subscribed!";
} else {
echo "Error: " . $sql . "<br>" . $con->error;
}

$con->close();
?>

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