Forum Moderators: coopster
<img src="https://www.ourdomain.com/scripts/sale.php?ID=<AFFILATE_ID>&ORDERNUMBER=%ORDERNUMBER%&AMT=%ORDERTOTAL% height="1" width="1">
My question is what script should we have in the sale.php page, so that the invisible image is loaded to the checkout_success page and data is collected and stored in SQL for further processing. Is there any free php script that will do the job? Or should I better post this on the E-commerce WM forum?
<?php
// Get the data being sent to us:
$AFFILATE_ID = (isset [php.net]($_GET [php.net]['AFFILATE_ID'])) ? $_GET['AFFILATE_ID'] : '';
$ORDERNUMBER = (isset($_GET['ORDERNUMBER'])) ? $_GET['ORDERNUMBER'] : '';
$ORDERTOTAL = (isset($_GET['ORDERTOTAL'])) ? $_GET['ORDERTOTAL'] : '';
// Connect to database:
// Note, most people keep this section outside the public realm and use
// a PHP include [php.net] to make the connection:
$db_server = 'localhost';
$db_user = 'db_user';
$db_pwd = 'db_pass';
$db_name = 'db_name';
if (mysql_connect [php.net]($db_server, $db_user, $db_pwd)) {
$AFFILATE_ID = mysql_real_escape_string [php.net]($AFFILATE_ID);
$ORDERNUMBER = mysql_real_escape_string [php.net]($ORDERNUMBER );
$ORDERTOTAL = mysql_real_escape_string [php.net]($ORDERTOTAL);
$query = "INSERT INTO trackingTable (affID, ordNbr, ordTtl) VALUES ('$AFFILATE_ID','$ORDERNUMBER','$ORDERTOTAL')";
mysql_query [php.net]($query);
}
// Send the image back:
header [php.net]("Content-type: image/png");
readfile [php.net]('mySinglePixelImageInThisDirectory.png');
exit;
?>