I am very new to AJAX, and this is for an assignment so we cannot use jquery or anything like that. I currently have a product list with a link to add an item, right now I just want it to echo back on the page "Item Added" when you click add item, and then the item to add to the cart.

I am going to have to be able to view the cart after but I need to tackle this one problem at a time as I'm very confused, where AJAX is concerned at the moment.

This is the code I have.

PRODUCT LIST PAGE

<?php
session_start();
require_once('connect.php');
?>
<html>
<head>
<title>Product List</title>
</head>
<body>
<table width="600" border="0">
<?php
if(isset($_SESSION['username'])) {
echo "Welcome Back, ".$_SESSION['username']."<br />";
print_r($_SESSION);
echo count($_SESSION);
echo "<br /><br />";
showProducts();
}else{
echo "not logged in";
}

function showProducts() {
$querystring = "SELECT * FROM tbl_products ORDER BY product_price DESC";
$productlist = mysql_query($querystring);
while($row = mysql_fetch_array($productlist)) {
echo "<tr><td>".$row['product_name']."</td><td>".$row['product_price']."</td><td><a href=add_product.php?productnumber=".$row['product_id']."&productprice=".$row['product_price'].">add to cart</a></td></tr>";
}
echo "<tr><td></td></tr><tr><td><a href=\"view_cart.php\">view cart</a></td></tr>";
}
?>
</table>
<div id="product">

</div>
</body>
</html>


ADD_PRODUCT.PHP

<?php
session_start();
$_SESSION['purchases']++;
$_SESSION['clickcount']++;
$newitem = "item".$_SESSION['purchases'];
$newprice = "price".$_SESSION['purchases'];
$_SESSION[$newitem] = $_GET['productnumber'];
$_SESSION[$newprice] = $_GET['productprice'];
header("Location: product_list.php");

?>