Jump to content

[SOLVED] Send Session array to IP address


ukphoto

Recommended Posts

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

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.