I'm working with a product list for a shopping system.
When a user goes to the shop, they get a UID. Once the user adds an item to the cart, i give them a category number (for shipping/discount purposes).
when user first goes to site:
http://domain.com/dir/file.php?UID=12ahdy32124h45
after first item in cart:
http://domain.com/dir/file.php?UID=12ahdy32124h45&CA=1
after subsequent items in cart: (should stay the same)
http://domain.com/dir/file.php?UID=12ahdy32124h45&CA=1
now the problem is, after a user continues to add an items to the cart, they begin to get an URL like so:
http://domain.com/dir/file.php?UID=12ahdy32124h45&CA=1&CA=1&CA=1
What I am attemping to do is
if QUERY_STRING doesn't have CA in it (it doesn't matter its value)
then Add CA=$_POST['CA'] to the querystirng
else
leave URL and querystring alone.
redirect user to refferred page.
here's my code:
// file: order_dvd.php
echo "<FORM ACTION=\"".RELATIVE_URL."/do_process.php\" METHOD=\"POST\">";
echo "<INPUT TYPE=\"hidden\" NAME=\"CA\" VALUE=\"1\">";
// file: do_process.php
if(!$_GET['CA']){
$Q_STRING = "&CA=$CA";
}
/* I've also tried:
if(isset($_SERVER['CA'])){
$Q_STRING = "&CA=$CA";
}
*/
header("Location:". $_SERVER['HTTP_REFERER'] . $Q_STRING);
//Header("Location:$HTTP_REFERER$Q_STRING");
//Header("Location:".RELATIVE_URL."/viewCart.php?CA=$CA&UID=$UID");
Here's an actual example of my problem:
http://www.librarymedia.org/order/order_dvd.php
I'm not sure what is the problem. I've tried several things (as you can see in the code), but none of it works. maybe there could be a different approach for the solution?
thanks for any responses.