<?
include("dbconnect.php");
if($submit == 'Add Case(s) To Cart')
{?>
<SCRIPT LANGUAGE="JavaScript">
var qty = "<?echo $qty;?>";
var price = "<?echo $price;?>";
var pack = "<?echo $pack;?>";
var total = (pack * price);
var casetotal = (total * qty);
if (confirm("*** This is a Case Only Item ***\n\nThis means that the quantity you enter\nwill be the amount of case you buy and\nnot the amount of pieces.\n\n\t"+price+"\tCase Price\n\tx"+pack+"\tCase Pack\n\t-------------\n\t"+total+"\tUnit Total\n\tx"+qty+"\tQuantity\n\t-------------\n\n\t$"+casetotal+"\tOrder Total For This Item\n\nDo you want "+qty+" case(s) of this item?"))
{
}
else
{
history.go(-1);
exit;
}
</SCRIPT>
<?}
$query = "select * from storeOrders where
orderCustomerID = '$custID' and orderStatus = 'Pending'";
$mysql_result = mysql_query($query, $mysql_link);
$recordCount = 0;
$recordCount = mysql_affected_rows ($mysql_link);
if($recordCount == 0)
{
srand(time());
$orderNumber = (rand()%10000)+1;
}
else
{
while($row = mysql_fetch_row($mysql_result))
{
$orderNumber = $row[1];}
}
$query = "select * from storeOrders where orderCustomerID = '$custID' and orderStatus = 'Pending' and orderProductID = '$productID'";
$mysql_result = mysql_query($query, $mysql_link);
if(mysql_affected_rows() != 0)
{
print("<h2>Cannot Add Product Twice!</h2>\n<b>Please Change Quantities <a href=\"store.php?myAccount=My+Cart\">here</a></b>.");
exit();
}
else
{
$query = "insert into storeOrders (orderNumber, orderStatus, orderCustomerID, orderProductID, orderQuantity)values";
$query .= "('$orderNumber', 'Pending', '$custID', '$productID', '$qty')";
$mysql_result = mysql_query($query, $mysql_link);
}
?>
Shouldn't the javascript wait for a reply from the confirm box before is finishes this script??
It doesn't...once the box pops up, the item is already entered into the database as per the $query right below it.
Is there a way to stop this?