shopping cart - Page redirect not working PHP -


im trying redirect user when click "empty cart". redirect working "add cart" not "empty cart". ideas great.

in main .php file set current url seen

$current_url = base64_encode("http://$_server[http_host]$_server[request_uri]"); 

then below cartaction.php file handles actions such "add cart" , "empty cart"

<?php session_start(); include_once 'config.php';  //add item in shopping cart if(isset($_post["add"])) {     $product_id = $_post["product_id"]; //product id     $return_url = base64_decode($_post["return_url"]); //return url     $qty = $_post["qty"];     $product = $mysqli->query("select product_name, unit_price, unit_quantity products product_id = '$product_id'");     $obj = $product->fetch_object();      if(!isset($_session['products'])) {         $_session['products'] = array();     }      if(array_key_exists($product_id, $_session['products'])) {         $_session['products'][$product_id]['qty'] += $qty;         //redirect original page         header('location:'.$return_url);     }     else {         $_session['products'][$product_id] = array('name' => $obj->product_name, 'price' => $obj->unit_price, 'unit' => $obj->unit_quantity, 'qty' => $qty);      }      //redirect original page     header('location:'.$return_url); }  //empty cart distroying current session if(isset($_post["emptycart"])) {     $return_url = base64_decode($_post["return_url"]); //return url     session_destroy();     header('location:'.$return_url); } ?> 

"are sure $_post['return_url'] set? try var_dump , check value. " @ofirbaruch

"error_reporting(e_all); ini_set('display_errors', 1); @ top of php. guarantee you'll have useful." @devon

above appropriate answers/approaches problem.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -