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

标签 php mysql insert

每次我在 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/

相关文章:

mysql - 一次查询获得两个结果

插入后Android SQLite查询不返回数据

csv - 加载与变更日志文件相关的 CSV 文件

PHP DomDocument 类不存在

php - 无法在编辑时通过 codeIgniter 验证更改值

php - Base64 编码的字符串错误地保存到 MySQL

php - SQL : Copy from column to another column with replace space

php - MVC、DI(依赖注入(inject))和从 Controller 创建模型实例

php - 电子商务网站的货币转换 - 防止因四舍五入而导致购物车总数不正确

mysql - fork MySQL INSERT INTO (InnoDB)