Hi,
I've been using this script to start a customer profile (the field orderNum in 'customer' is auto_increment) and add items to a shopping cart (the table 'orderItem') using $_SESSION['orderNum'] to assign the orderNum to successive items.
But something prevents $_SESSION['orderNum'] from being passed to other pages; I've tested it several ways and it's just not available. The result is that the conditional block is executed every time I enter this page, creating a new customer every time. Whether or not I also use session_start() and/or session_register() also has no apparent effect. Any clues?
if (!isset($SESSION['orderNum']))
{
mysql_select_db($database_connectMyShop, $connectMyShop);
$query_init_cust = "INSERT INTO customer (orderNum) VALUES (NULL)";
mysql_query ($query_init_cust, $connectMyShop) or die(mysql_error());
$SESSION['orderNum'] = mysql_insert_id();
}
$query_cust_exists = "INSERT INTO orderitem (orderNum, Name, price, qty) VALUES
('".$SESSION['orderNum']."', '".$POST['Name']."', '".$POST['price']."', '".$POST['qty']."')";
mysql_query ($query_cust_exists, $connectMyShop) or die(mysql_error());