我需要將字段內的數據複製到另一個字段。插入記錄時,我需要將「reg」複製到「reg_copy」。有沒有辦法在我的腳本中做到這一點?在插入執行時將數據複製到另一個字段
<?
$order = "INSERT INTO reg_add (
connect_date,
reg,
reg_copy,
first_name,
last_name)
VALUES
('$_POST[connect_date]',
'$_POST[reg]',
'$_POST[reg_copy]',
'$_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");
}
?>
請閱讀:HTTP:/ /bobby-tables.com/和http://php.net/manual/en/language.types.string.php,注意在字符串中使用關聯數組值的語法。還請解釋你想要「複製」這些值的意思 - 將它們複製到/從哪裏? – DaveRandom 2012-04-24 14:23:56
爲什麼你不能使用$ _POST [reg]來插入? – daSn0wie 2012-04-24 14:24:07
爲什麼不直接插入'$ _POST [reg]'兩次?並請閱讀[SQL注入](http://php.net/manual/en/security.database.sql-injection.php) – ManseUK 2012-04-24 14:24:17