i need to ajaxify this code and remove header location option in php. i want the user remain on same page after clicking add to cart button .....any help is highly appreciated My javascript
<script language="javascript">
function addtocart(pid){
document.form1.productid.value=pid;
document.form1.command.value='add';
document.form1.submit();
}
</script>
<?php
if($_REQUEST['command']=='add' && $_REQUEST['productid']>0){
$pid=$_REQUEST['productid'];
addtocart($pid,1);
header("location:shoppingcart.php");
exit();
}
?>
displaying products
<form name="form1">
<input type="hidden" name="productid" />
<input type="hidden" name="command" />
</form>
<?php echo $row['picture']?>" />
<b><?php echo $row['name']?></b><br />
<?php echo $row['description']?><br />
Price:<big style="color:green">
$<?php echo $row['price']?></big><br /><br />
<input type="button"
value="Add to Cart" onclick="addtocart(<?php echo $row['serial']?>)" />
part of my shopping cart
<?php
if($_REQUEST['command']=='delete' && $_REQUEST['pid']>0){
remove_product($_REQUEST['pid']);
}
else if($_REQUEST['command']=='clear'){
unset($_SESSION['cart']);
}
else if($_REQUEST['command']=='update'){
$max=count($_SESSION['cart']);
for($i=0;$i<$max;$i++){
$pid=$_SESSION['cart'][$i]['productid'];
$q=intval($_REQUEST['product'.$pid]);
if($q>0 && $q<=999){
$_SESSION['cart'][$i]['qty']=$q;
}
else{ $msg='Some proudcts
not updated!, quantity must be a number
between 1 and 999';
}
}
}
?>