<?php

session_start();

ob_start();


//if($_SESSION['ship']==""){
//	
//header("location: checkout.php?error=yes");	
//}



include_once("dbconnect.php");

 $sql="insert into tblcart(userid,grandtotal,status,prototal,ship,tax,method) values('".$_SESSION['userid']."','".round($_SESSION['totalamounttax'],2)."','0','".round($_SESSION['totalamount'],2)."','".round($_SESSION['ship'],2)."','".round($_SESSION['tax'],2)."','".$_SESSION['service']."')";
 

 if(mysql_query($sql))

    {

	 $cid=mysql_insert_id();

	 $_SESSION['petercart_id']=$cid;

	$k=$_SESSION['idlcount']; 

	for($i=1;$i<=$k;$i++)

    {

   $query="insert into tblcartdetails(cartid,productid,qty,UNITPRICE,total,status,pname)values(".$cid.",".$_SESSION['idlcart'][$i]["prodid"].",".$_SESSION['idlcart'][$i]["qty"].",".$_SESSION['idlcart'][$i]["price"].",".$_SESSION['idlcart'][$i]["totprice"].",0,'".$_SESSION['idlcart'][$i]["pname"]."')"; 
	

	$fdsfs=mysql_query($query);    

}


header("Location:finalpayment.php");

}

	

	

 ?>