Let me help you PHP friends out. After all, what's a community for?
First, I've created a DB table called 'purchases' with the following vars:
first_name
last_name
payer_email
payment_date
custom
invoice
item_name
item_number
Why? Because these are the only items I want to know about a purchase. Feel free to add your own.
Now for the PHP code.
<?php
//since all this happens invisibly between servers, we can't see errors, so email myself all the bugs that happen
function emailOnFail($var)
{
mail ("YOUR_EMAIL_ADDRESS_HERE","post from e-junkie", print_r($_POST) . $var);
}
//First, check if the server that triggered this page to load is sending the right handshake
if ($POST['handshake']!==md5("YOUREJUNKIE_EMAIL_HERE".md5("YOUR_EJUNKIE_PASSWORD_HERE")))
{
//The server is not legit, so exit to prevent this fraud from happening.
die();
}
//Connect to the MySQL database
mysql_connect("DB_HOST_HERE", "DB_USER_HERE", "DB_PASSWORD_HERE") or die(emailOnFail("MYSQL ERROR! ".mysql_error()));
mysql_select_db("DB_NAME_HERE") or die(emailOnFail("DB-SELECT ERROR! ".mysql_error()));
//Multiple items could have been purchased so go through the list to see how many items have been purchased; I'm capping it at 1000
$i = 1000;
$count = 1;
while ($i>$count)
{
if($POST['itemnumber'.$count])
{
//We need to know the following variables (left: e-junkie var, right: database var):
/*
first_name = first_name
last_name = last_name
payer_email = payer_email
payment_date = payment_date
custom = YouTubeChannel
invoice = invoice
item_name = item_name
item_number = item_number
*/
//set the vars to a database array (left: db var, right: e-junkie var)
//WARNING: You should probably check if these post-vars actually exist!
$db['first_name'] = $POST['firstname'];
$db['last_name'] = $POST['lastname'];
$db['payer_email'] = $POST['payeremail'];
$db['payment_date'] = $POST['paymentdate'];
$db['YouTubeChannel'] = $_POST['custom'];
$db['invoice'] = $_POST['invoice'];
$db['item_name'] = $POST['itemname'.$count.''];
$db['item_number'] = $POST['itemnumber'.$count.''];
//extract the database array into a query
$string = "INSERT INTO purchases (first_name, last_name, payer_email, payment_date, YouTubeChannel, invoice, item_name, item_number)
VALUES('".$db['first_name']."',
'".$db['last_name']."',
'".$db['payer_email']."',
'".$db['payment_date']."',
'".$db['YouTubeChannel']."',
'".$db['invoice']."',
'".$db['item_name']."',
'".$db['item_number']."'
)";
//fire it into the db or die with an email notification
mysql_query($string) or die(emailOnFail("DB-INSERT ERROR! ".mysql_error()));
}
else
{
//there are no items left in the cart, so kill this script. All done!
$finalcount = $count;
$count = 1001;
break;
die();
}
//There are more items left in the script so go back and do some more!
$count++;
}
?>