Remove the echo $_POST['sub'];
from the else
part which is responsible for this Undefined index notice
and replace with the echo
statement.
Should be like this..
<?php
if (isset($_POST['sub']) && $_POST['sub']=="ritem") {
$id=$_POST['ritemid'];
unset ($_SESSION['cart']['items'][$id]);
header("Location: ".$_SERVER['HTTP_REFERER']."");die();}
else
{
echo "The subject is not set";
}
That is because.. when the if
fails which means the $_POST['sub']
is not set , so when it comes to the else
part , you are trying to output $_POST['sub']
which was actually not set (which is actual source of this problem)