I have a webpage for a product store split into three frames
top_half
- Displays the product details and quantity that the user wants to add when a product is selected.bottom_half
of the frame displays the shopping cart when I select 'Submit' in the top half.I want to submit the information from the shopping cart(bottom_half
) to display the contents in the top_half
as well as an order form for customer details.. this will close the session and display " to complete checkout please fill in the information above"
Cart.php (bottom_half)
<?php
session_start();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Grocery Store</title>
<link rel="stylesheet" type="text/css" href="CSS_prod.css">
</head>
<body>
<h2>My Shopping Cart</h2>
<?php
if(isset($_POST['empty_cart']))
{
$_SESSION=array();
session_desrtoy();
}
require_once 'class_product.php';
$product = unserialize($_SESSION['product']);
$quantity = $_POST['cart'];
$total_price = 0;
echo '<table class="Checkout">';
echo "<tr>";
echo "<th>Product Name</th>";
echo "<th>Product Id </th>";
echo "<th>In Stock</th>";
echo "<th>Price</th>";
echo "<th>Quantity Added</th>";
echo "<th>Cost</th>";
echo "</tr>";
if(!isSet($_SESSION['cart_items']))
{
$_SESSION['cart_items'] = array();
}
array_push($_SESSION['cart_items'],$product->getProductName()."|".$product->getProductId()."|".$product->getStock()."|".$product->getUnitPrice()."|".$quantity."|".$sub_total);
for($i=0;$i<sizeof($_SESSION['cart_items']);$i++)
{
$sub_total = $product->getUnitPrice() * $quantity;
$total_price += $sub_total;
echo "<tr>";
//echo $_SESSION['cart_items'][$i]."<br><hr>";
$params = explode("|",$_SESSION['cart_items'][$i]);
for($j=0;$j<sizeof($params);$j++)
{
if($j == 0)
{
echo "<th>".$params[$j]."</th>";
}
else
{
echo "<td>".$params[$j]."</td>";
}
}
echo "</tr>";
}
echo"<tr>";
echo "<td></td>";
echo "<td></td>";
echo "<td></td>";
echo "<td></td>";
echo "<td>Total Cost</td>";
echo "<td>$total_price</td>";
echo"</tr>";
echo "</table>";
?>
<form name="endform" method="post">
<button type="submit" name="empty_cart" value="Delete" id="empty_cart">Delete</button>
<button type="submit" name="Checkout" value="Checkout" onlcick="purchase.php">Checkout</button>
</form>
</body>
</html>