Re: session_name("CCLTrolley")

From: Date: Mon, 03 Oct 2005 05:43:01 +0000
Subject: Re: session_name("CCLTrolley")
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-223549@lists.php.net to get a copy of this message
This is the old version I demonstrated. You should go with the later version that sets the values to the quantity :)
I thought I had? Haven't I? But this is the easiest shopping cart I have ever seen. However, I still have not understood what you were doing with these lines I commented out. if( isset( $_SESSION['TrolleyContents'][$_POST['RNum']] ) ) {
   #    $_SESSION['TrolleyContents'][$_POST['RNum']] -= 1;
   #    if( $_SESSION['TrolleyContents'][$_POST['RNum']] <= 0 )
   #    {
           unset( $_SESSION['TrolleyContents'][$_POST['RNum']] );
   #    }
They did not work, or seem to? John ---------------snip-------------------- http://testesp.flsh.usherbrooke.ca/db/trolley.php Array ( [TrolleyContents] => Array ( [2378] => 2378 [2504] => 2504 ) ) ) ---------------snip-------------------- <?php session_name( 'CCLTrolley' ); session_start(); // Initialize the trolley. if( !isset( $_SESSION['TrolleyContents'] ) ) { $_SESSION['TrolleyContents'] = array(); } echo $_POST['ShopAction']."!!<br>"; if("add" == $_POST['ShopAction']) { echo "adding ..."; // Add new entry: if( isset( $_POST['RNum'] ) ) {
       $_SESSION['TrolleyContents'][$_POST['RNum']] = $_POST['RNum'];
} echo implode( ',', $_SESSION['TrolleyContents'] ); #echo $_POST['RNum']."!!<br>"; }else{ echo "deleting ..."; //Delete an entry: if( isset( $_SESSION['TrolleyContents'][$_POST['RNum']] ) ) {
   #    $_SESSION['TrolleyContents'][$_POST['RNum']] -= 1;
   #    if( $_SESSION['TrolleyContents'][$_POST['RNum']] <= 0 )
   #    {
           unset( $_SESSION['TrolleyContents'][$_POST['RNum']] );
   #    }
} } print_r( $_SESSION ); ?> --------Delete form: snip ------- <form ACTION="trolley.php" METHOD="POST"> <input type="hidden" name="RNum" value="2378"> <input type="hidden" name="searchenquiry" value="Taylor-Johnston, John"><input type="hidden" name="ShopAction" value="delete"> <input type="image" name="submit" src="/icon/full3.gif" border="0" alt="Delete" title="Delete" style="padding-right: 5px;"><br><small>Delete</small></form> --------Add form: snip ------- <form targt="printwindow" ACTION="trolley.php" METHOD="POST"> <input type="hidden" name="RNum" value="2504"> <input type="hidden" name="searchenquiry" value="John Taylor-Johnston"><input type="hidden" name="ShopAction" value="add"> <input type="image" name="submit" src="/icon/empty3.gif" border="0" alt="Add to cart" title="Add to cart" style="padding-right: 5px;"><br><small>Add to cart</small></form>

« previous php.general (#223549) next »