Friday, March 21, 2014

Small Shopping Cart Example With session Using php

<?php
session_start();
$cart="";
if (isset($_POST['domainadd']))
{
    $domain = $_POST['domainadd'];
    $cart = $_SESSION['cart'];
    $cart[] = $domain;
    $_SESSION['cart'] = $cart;
}
if ($cart)
{
print("<table border=2 width=200>");
for($j=0;$j<count($cart);$j++){
print "<tr><td>". $cart[$j] ."<a><span class=style7>[remove]</span></a></td></tr>";
}
print("</table>");
}
?>
<form method="post">
<input name='domainadd' type="text">
<input type="submit" name="submit">