Hi folks,
I have an order form built in PHP which submits the data to an AJAX script for storage in a database, BEFORE it then goes to Google Checkout for the order to be prcessed.
It all seems to work just fine and well in IE 7 & 8, but not in Safari, Firefox in Windows.
cart.php code:
Here’s the AJAX part:
<script type="text/javascript">
<!--
function addBand(count, band){
var count1 = count;
var band1 = band;
alert("BAND ID: "+band1+" & TICKETS: "+count1);
if (count1=="" || band1==""){
alert("NO BAND SELECTED");
return false;
}
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}else{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","addbands2.php?band="+band1+"&count="+count1,true);
xmlhttp.send(null);
}
//-->
</script>
The form is as follows (a renderred version to save me having to post all the PHP include code):
<form method="POST" action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/326432977035812" accept-charset="utf-8" onSubmit="addBand(6,4968);">
<!-- Sell physical goods and services with possible tax and shipping -->
<input type="hidden" name="item_name_1" value="Adult Weekend Ticket (18+, Free Camping and Parking)"/>
<input type="hidden" name="item_description_1" value="GB 2011 - Entry Ticket (supporting Alice and Jono)"/>
<input type="hidden" name="item_price_1" value="58.00"/>
<input type="hidden" name="item_currency_1" value="GBP"/>
<input type="hidden" name="item_quantity_1" value="6"/>
<input type="hidden" name="_charset_" />
<!-- Button code -->
<input type="image" name="Google Checkout" alt="Fast checkout through Google" src="images/buttons/preceed.gif?merchant_id=326432977035812&w=214&h=59&style=trans&variant=text&loc=en_GB" height="59" width="214" border="0" />
</form>
Which when submitted called the addBand() AJAX script, which in turns calls the addbands2.php script before submitting the order to Google.
addbands.php script is as follows:
<?php
$con = mysql_connect("localhost","****","****");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("****", $con);
$band_nid = $_GET['band'];
$query2 = mysql_query("SELECT field_tickets_sold_value FROM content_type_act WHERE nid = ".$band_nid);
$result2 = mysql_fetch_array($query2);
$newCount = $result2['field_tickets_sold_value']+$_GET['count'];
$updateBand = mysql_query("UPDATE content_type_act SET field_tickets_sold_value = ".$newCount." WHERE nid = ".$band_nid);
$process = mysql_fetch_array($updateBand);
?>
So could anyone please help me with an answer as to why it is working fine in IE 7 & 8, but not Firefox or Safari?
Any help would be much appreciated, as I just can’t seem to see the wood for the trees.
Cheers,
Drakash