This one may take a little but please stay with me for it.
I have been working with this code:
if(isset($_GET['o']) && isset($_GET['q'])){
echo("WIN 1");
if($_GET['o'] == "remove") {
echo("WIN 2");
$_SESSION['product_'.$_GET['q']]-=1;
echo("WIN 3");
if($_SESSION['product_'.$_GET['q']] < 1) {
unset($_SESSION['product_'.$_GET['q']]);
echo("WIN 4");
redirect("checkout.php");
} else {
echo("LOSE");
redirect("checkout.php");
}
}
}
And it is not performing any of the functions unless I step through it using:
exit();
After each of the echos. I have no idea what could be causing this issue.
The URL being passed is:
localhost/cart.php?q=1&o=remove
Thank you!
EDIT
This is how I set the session (I have removed the echos):
if(isset($_GET['q'])) {
$query = query("SELECT * FROM products WHERE product_id=".escape_string($_GET['q'])."");
confirm($query);
while($row = fetch_array($query)){
if($row['product_quantity'] != $_SESSION['product_'.$_GET['q']]){
$_SESSION['product_'.$_GET['q']]+=1;
redirect("checkout.php");
} else if($row['product_quantity_tracking'] == "No") { //CHECK TO SEE IF IT'S INVENTORY TRACKED
redirect("checkout.php");
} else {
set_message("Sorry! There isn't enough in stock to complete that request!");
redirect("checkout.php");
}
}
}
This is the redirect function:
function redirect($location){
header("Location: $location");
}
I hope this helps!