Hi,
I am having a problem with my session in a basket function any help would be greatly appreciated i have posted the full page bellow.
[code=php]
<?php
session_start();
print_r($_SESSION["order"]);
echo '<BR>------------------<BR>';
if(isset($_GET[Destroy_basket]))
{
unset($SESSION);
session_destroy();
unset($order);
$info = 'Basket destroyed<BR>';
}
if(!isset($_SESSION['order']))
{
$info.='array made';
$order = array();
}
else $order=$_SESSION['order'];
print_r($order);
if(isset($_POST['submit']))
{
echo 'post submit set<BR>';
for($count=0;$product=$order[$count]['product_ID'];$count++)
{
if($product==$_POST['product_ID'])
{
$order[$count]['quantity']=$_POST['quantity'];
$already_exists=1;
}
echo '<BR>'.$count;
}
//echo 'product id is : '.$_POST[product_ID];
if($_POST[quantity] > 0&&isset($_POST['product_ID'])&&$already_exists!=1)
{
$order[] = array('product_ID' => $_POST['product_ID'], 'quantity' => $_POST['quantity']);
$info.=' quanity set '.$_POST["quantity"];
//echo 'order and session set<BR>';
}
else echo 'quanity or product id problem<BR>';
$_SESSION['order'] = $order;
//print_r($_SESSION["order"]);
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="Mystyles.css">
<title>HTML</title>
</head>
<BODY style="text-align: right;">
<BR><A href=basket.php?Destroy_basket>Empty and destroy basket</A>
<DIV class="PAGE">
<table width="100%">
<TR>
<TD>
<A href="index.php">
<img border="0" src="title.gif">
</A>
</TD>
<td>
<DIV class="SEARCH2">
<form method="get" action="search.php">
<input type="text" name="search" size="25" maxlength="255" value="" />
<input type="submit" value="Search" />
</form>
</DIV>
</td>
</TR>
</table>
<DIV class=NAV>
<UL>
<LI class=NAV><A class=NAV href=index.php>home</A></LI>
<LI class=NAV><A class=NAV href=products.php>products</A></LI>
<LI class=NAV><A class=NAV href=basket.php>basket</A></LI>
<LI class=NAV><A class=NAV href=login.php>login</A></LI>
</UL>
</DIV>
<TABLE width="100%">
<TR>
<TD class="MAIN">
<div class="SUBTITLE">
<p class="SUBTITLE">
My Basket
</p>
</div>
</TD>
</TR>
<TR>
<TD class="MAIN">
<?php
echo $info.'<BR>';
include("connect.php");
connect();
foreach($order as $product)
{
$query=sprintf('SELECT * FROM products WHERE product_ID=%s;',$product['product_ID']);
$result = mysql_query($query) or die(mysql_error());
$record=mysql_fetch_array($result);
echo '<LI class=PRODUCTS><H4><A href="products.php?product_ID='.$record["product_ID"].'">'.$record["title"].'</A></H4>'.$record["description"].'<BR><P class=PRODUCTS_PRICE>Price : £'.$record["price"].'</P><BR>
<FORM action=basket.php method=post>
<label>Quanity:</label>
<input name=quantity type=text maxlength=3 size=3 value='.$product['quantity'].'>
<input type="hidden" name="product_ID" value="'.$record["product_ID"].'">
<input type=submit name=submit value=update>
</FORM>
</LI><BR>';
// echo $record["product_ID"];
}
disconnect();
?>
</TD>
</TR>
</table>
<BR><A href=products.php>Continue shopping</A>
<BR><A href=basket.php?Destroy_basket>Empty and destroy basket</A>
</DIV>
</body>
</html>
[/code]
The print_r at the top of the code works in firefox, but not opera or IE.
please help even a link to a page that i can read and gain an understanding of what i am doing wrong.
thanks for your time.
Hoffmeister