ukphoto Posted March 27, 2008 Share Posted March 27, 2008 I have the following code which I can add items to a shopping cart and view the contents of the cart. What I want to be able to do is send a message to the server with the contents of the cart. This is on a totally stand alone network so there are no security issues to worry about. I do not really want to increase the complexity by having to run a mail server. Thanks in advance for looking. <?php session_start(); session_register('itemsInBasket'); $item=$_POST['item']; $quantity=$_POST['quantity']; $itemsInBasket=$_SESSION['itemsInBasket']; if ($item){ if (!isset($itemsInBasket)){ $itemsInBasket[$item]=$quantity; }else{ foreach($itemsInBasket as $k => $v){ if ($item==$k){ $itemsInBasket[$k]+=$quantity; $found=1; } } if (!$found) $itemsInBasket[$item]=$quantity; } } $_SESSION['itemsInBasket']=$itemsInBasket; ?> <html> <body> <form action="shopcartalpha.php" method="post"> Item <input type="text" name="item" size="20"><br> Quantity <input type="text" name="quantity" size="20"><br> <input type="submit" value="Add to Order"><br> </form> <?php if (isset($itemsInBasket)){ echo'The contents of the basket are:<br>'; foreach($itemsInBasket as $k => $v){ echo 'Image: '.$k.' Qty: '.$v.'<br>'; } } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/98148-solved-send-session-array-to-ip-address/ Share on other sites More sharing options...
BlueSkyIS Posted March 27, 2008 Share Posted March 27, 2008 i suggest that instead of sending the contents to the server that you have the server connect to the same database and pull the contents, given a shopping cart id or similar. Link to comment https://forums.phpfreaks.com/topic/98148-solved-send-session-array-to-ip-address/#findComment-502199 Share on other sites More sharing options...
ukphoto Posted March 27, 2008 Author Share Posted March 27, 2008 My intention was to avoid the use of a database where possible and stick to pure php. Link to comment https://forums.phpfreaks.com/topic/98148-solved-send-session-array-to-ip-address/#findComment-502221 Share on other sites More sharing options...
discomatt Posted March 27, 2008 Share Posted March 27, 2008 I tink you need to describe what you're doing a little better. Did you want the client to send that information to the server, or the script? Link to comment https://forums.phpfreaks.com/topic/98148-solved-send-session-array-to-ip-address/#findComment-502229 Share on other sites More sharing options...
ukphoto Posted March 27, 2008 Author Share Posted March 27, 2008 The intention is that there will be numerous items over numerous pages that can be added to the session array and at some stage the user will submit the array to the server, hopefully in the form of a message. Link to comment https://forums.phpfreaks.com/topic/98148-solved-send-session-array-to-ip-address/#findComment-502240 Share on other sites More sharing options...
ukphoto Posted April 11, 2008 Author Share Posted April 11, 2008 Gave up with trying to do it in pure php and used mysql which has given more possibilities. Mike Link to comment https://forums.phpfreaks.com/topic/98148-solved-send-session-array-to-ip-address/#findComment-514606 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.