Jump to content

Archived

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

redarrow

add to basket help

Recommended Posts


how can i add to basket with sessions so if the user press add to basket the session adds the items up and shows the product.

please help thank you.

my example

[code]
<? session_start();


$product="tv";
$for_sale=$_SESSION["tv"]=$product;

$price=10;
$on_sale=$_SESSION["price"]=$price;

echo "<br>price $on_sale<br> product $for_sale<br>";

?>
<html>
<body>

<form method="post" action"">
<input type="text" name="for_sale" value="<? echo $for_sale ?>">
<input type="text" name="on_sale" value="<? echo $on_sale ?>">
<input type="submit" value="add to basket">
</form>
</body>
</html>

<?

$product="hi fi";
$for_sale=$_SESSION["tv"]=$product;

$price=20;
$on_sale=$_SESSION["price"]=$price;

echo "<br>price $on_sale<br> product $for_sale<br>";

?>


<form method="post" action"">
<input type="text" name="for_sale" value="<? echo $for_sale ?>">
<input type="text" name="on_sale" value="<? echo $on_sale ?>">
<input type="submit" value="add to basket">
</form>
</body>
</html>

<?

if(!$_POST['submit']) {

$on_sale+$on_sale;

echo"Your Basket<br>product $for_sale<br>total price $on_sale ";
}
?>
[/code]

Share this post


Link to post
Share on other sites

×

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.