删除有效,页面重定向,但删除后的 url 是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();
}