-2
請我想從特定表中刪除一條記錄,並將相同的記錄插入另一個表。這是工作正常,如果所有的表都包含相同的列,但我需要添加另一列到刪除的記錄被插入的表。在另一個表中添加列的多個查詢
這裏是我的代碼謝謝
<?php
// connect to the database
$con=mysqli_connect("localhost", "root", "");
if(mysqli_select_db($con, "e-office"));
$execute ='';
$Posting_User = mysqli_escape_string($con, $_SESSION[('Uname')]);
// confirm that the 'id' variable has been set
if (isset($_GET['execute'])) $execute = $_GET['execute'];
{
// get the 'id' variable from the URL
if($execute=='delete'){
$id = $_GET['id'];
// delete record from database
$sql = mysqli_query($con, "INSERT INTO tbl_income_approved SELECT * FROM
tbl_income WHERE (trn_no = '$id' AND Approved_by ='$Posting_User') ");
$sql = mysqli_query($con, "DELETE FROM tbl_income WHERE trn_no = '$id'");
if($sql)
// redirect user after delete is successful
header("Location: income_report.php");
else
// if the 'id' variable isn't set, redirect the user
echo "query not successful";
}
}
?>
請問您可以在這個問題上解釋C#和Adobe標記,還是我錯過了什麼? –
**您可以[SQL注入](http://php.net/manual/en/security.database.sql-injection.php)**,並確實使用** [Prepared Statements](http: //php.net/manual/en/mysqli.quickstart.prepared-statements.php)**,而不是串聯你的查詢。特別是因爲你沒有逃避用戶輸入! –
感謝Nileshsinh Rathod的編輯。 Magnus我計劃在最終實施之前逃脫我的用戶輸入。 – AbubakarRuma