I’m trying to make the update qty script for our cart work so it stays on the page you are on, eg, if the qty is changed at stage 3 of the cart the qty updates & you stay on cart 3. Currently it would take you back to cart stage 1!
The code currently looks like this :-
[php]<?php
session_start();
if ( $_SESSION[‘locked’] != 1 )
{
include_once(“config.php”);
if ( ( !isset($_POST[‘cartitem’]) ) || ( $_POST[‘cartitem’] == ‘’ ) )
{
include_once(“top.php”);
echo ‘Please go back and select a product to change the quantity of from your cart.’;
include_once(“bottom.php”);
}
else
{
if ( $_POST[‘quantity’] == ‘0’ )
{
$sql = “UPDATE cartitems SET active=‘0’ WHERE cartitemid=’”.mysql_real_escape_string($_POST[‘cartitem’])."’";
mysql_query($sql);
}
else
{
$sql = “UPDATE cartitems SET quantity=’”.$_POST[‘quantity’]."’ WHERE cartitemid=’".mysql_real_escape_string($_POST[‘cartitem’])."’";
mysql_query($sql);
}
header (“Location: cart.php”);
}
}
else
{
header (“Location: cart.php”);
}
?>[/php]
I tried modifying the link on each cart page so rather than the script called as I changed it to for cart1.php then cartpage=b for cart2.php etc. I then modified the script attached as follows :-
[php]include_once(“bottom.php”);
}
else
{
if ( $_POST[‘quantity’] == ‘0’ )
{
$sql = “UPDATE cartitems SET active=‘0’ WHERE cartitemid=’”.mysql_real_escape_string($_POST[‘cartitem’])."’";
mysql_query($sql);
}
else
{
$sql = “UPDATE cartitems SET quantity=’”.$_POST[‘quantity’]."’ WHERE cartitemid=’".mysql_real_escape_string($_POST[‘cartitem’])."’";
mysql_query($sql);
}
header (“Location: cart.php”);
}
}
else
{
if ( $_GET[‘cartpage’] == “a” )
{
header (“Location: cart.php”);
}
if ( $_GET[‘cartpage’] == “b” )
{
header (“Location: cart2.php”);
}
if ( $_GET[‘cartpage’] == “c” )
{
header (“Location: cart3.php”);
}
}
?>[/php]
But it didn’t work, can anyone suggest how I can get this to work. I know nothing about PHP so i’m just trying my best here.
Thanks for any help anyone can offer