刪除工程和頁面重定向,但刪除後的網址是http://localhost:/manage_items.php?yesdelete=23
這是爲什麼?它應該是之前的任何類型的輸出去的瀏覽器才能正常工作manage_items.php
沒有正確重定向與標題
while ($row = $get_products->fetch()) {
$item_id = $row['item_id'];
$user_id = $row['user_id'];
$item_name = $row['item_name'];
$date = $row['add_date'];
$image = $row['photopath'];
$products .= "<br/><img src = $image><img> Item ID: $item_id UserID: $user_id NAME:
$item_name Added on: $date  
<a href='item_edit.php?pid=$item_id'>Edit</a> 
<a href='manage_items.php?deleted=$item_id'>Delete</a>";
}
//delete Item
if(isset($_GET['deleted'])) {
echo 'delete this product?'.$_GET['deleted'].'<a
href="manage_items.php?yesdelete='.$_GET['deleted'].'">Yes<a/>
/<a href ="manage_items.php">No</a>';
exit();
}
if(isset($_GET['yesdelete'])) {
$deleteid = $_GET['yesdelete'];
$sql = $db->exec("DELETE FROM item WHERE `item_id` = '$deleteid' LIMIT 1");
$image_delete = 'file_to/$deleteid';
if(file_exists($image_delete)) {
unlink($image_delete);
}
header("Location: manage_items.php");
exit();
}
_1._ **你的代碼是容易受到SQL注入** ** _2._你的代碼很容易受到XSS * * –
@NullPoiиteя是的,我知道,但這不是我關心的問題。 – rogerthat
你有什麼錯誤嗎? – bansi