Hi
I am tryin to create a shopping basket using sessions. the first page starts the session sessiontrolley.php
<?php
session_start(); // Initialise session
session_register("trolleyContents"); // Register our variables
?>
<form method="post" action="sessiontrolley2.php?<?=SID?>">
Choose an item: </p>
<input type="radio" name="choice" value="camera" /> camera<br />
<input type="radio" name="choice" value="snorkel" /> snorkel<br />
<input type="radio" name="choice" value="octopus" /> octopus<br />
<input type="radio" name="choice" value="cuddly toy" /> cuddly toy<br /><br />
<input type="submit" name="submit" value="Add to the trolley" />
</form>
and the second page displays the selected product sessiontrolley2.php
<?php
if ((!$trolleyContents && !$choice) || $clear) {
$trolleyContents = "";
echo "<p>Trolley currently empty</p>";
} else {
if ( $choice ) $trolleyContents = $trolleyContents . "<li>$choice</li>";
echo "<p>Trolley contains:</p>";
echo "<ul>$trolleyContents</ul>";
}
echo ("<a href=\"http://stuweb.cms.gre.ac.uk/~lj917/sessiontrolley.php\"> Continue shopping<a/>");
?>
Every time i go back to the sessiontrolley.php i want to add a new product to the trolley. What happens at the moment is that the product gets replaced with te new one. does anyone know how to solve this? I have also tried to start the session in a page before sessiontrolley.php but it still doesn't store my products.😕