无法修改标头信息 - 标头

时间:2015-12-04 15:18:25

标签: php html

点击超链接后,我收到以下警告。我按照此链接中给出的解决方案:How to fix "Headers already sent" error in PHP但我无法使我的代码工作。它仍然给我警告,并没有重定向到下一页,即在remove_from_cart.php中给出。请提出任何建议。

  

警告:无法修改标题信息 - 已在第4行的D:\ remove_from_cart.php中发送的标题(输出从D:\ index.php:188开始)

代码

<a href="index.php?page=remove_from_cart&action=remove&id=<?php echo $row['productid']; ?>">X</a>

remove_from_cart.php

<?php
$id = isset($_GET['id']) ? $_GET['id'] : "";
unset($_SESSION['cart'][$id]);
header('Location: index.php?page=cart&id='.$id  );
?>

1 个答案:

答案 0 :(得分:0)

更改此

echo "Removed id:".$id;//you cannot echo here
header('Location: index.php'  );

header('Location: index.php?id='.$id  );
exit();// good practice to exit after header().