gpt4 book ai didi

php - 在插入时为输入数据添加后缀。这可能吗? (MySQL/PHP)

转载 作者:行者123 更新时间:2023-11-29 04:26:32 25 4
gpt4 key购买 nike

每次我在 mySQL 中插入一条新记录时,我都需要在 reg 数据的末尾添加字母“v”作为后缀。

这是我的插入脚本。是否可以在客户端提交此PHP操作插入时将字母“v”放置到reg数据中?

<?
$order = "INSERT INTO reg_add (
connect_date,
reg,
first_name,
last_name)

VALUES

('$_POST[connect_date]',
'$_POST[reg]',
'$_POST[first_name]',
'$_POST[last_name]')";

$result = mysql_query($order);

if ($result) {

$reg = $_REQUEST['reg'] ;
$first_name = $_REQUEST['first_name'];

header("location: reg_add_success.php?reg=" . urlencode($reg) . "&first_name=" . urlencode($first_name));
}
else {
header("location: reg_add_fail.php");
}
?>

最佳答案

你正在做的事情非常危险。您基本上是在向恶意用户提供执行 sql 注入(inject)所需的一切。

收集您的值,验证它们不包含任何恶意代码,然后执行您的插入(已添加您想要的任何后缀)!!

说真的......这是一场注定会发生的灾难。

检查一下: http://www.unixwiz.net/techtips/sql-injection.html

关于php - 在插入时为输入数据添加后缀。这可能吗? (MySQL/PHP),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10291820/

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