Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

Automatic insert record from URL ? is it possible

Posted 08 Aug 2006 23:05:58
1
has voted
08 Aug 2006 23:05:58 rob hewitt posted:
I'm a bit of a newbie & am trying to set up pages for registration of members where they input their details & then submit to WorldPay to make payment. Worldpay sends a 'callback' script to any page i choose with confirmation details of the transaction which i would use to insert a new paid up member. Their guides state the callback is usually sent to something like a cgi script but it could be php to receive the 'callback' & then automatically input new member details into a database.

eg: callback from WorldPay would point to www.mysite.com/paid.php & the data from WorldPay is attached - /paid.php?name=xyz?transId=123 etc etc

I have no idea how to write cgi scripts - i use dreamweaver 8.02. PHP & MySQL

Is there a way i can modify the following 'insert record' code from a page i was trying so the 'callback' from Worldpay is automatically inserted into a table.

hopefully just have the code from the '$insertSQL' statement.. The code from my insert record is below

<?php require_once('../Connections/dancingin.php'); ?>
<?php
if (!function_exists("GetSQLValueString") {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = ""
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string" ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "" ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "" ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "" ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "" ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "" ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1") {
$insertSQL = sprintf("INSERT INTO newsletter (Name, Address, PostCode, email, Amount, transId, cartId, transStatus, testMode) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['MC_Name'], "text",
GetSQLValueString($_POST['address'], "text",
GetSQLValueString($_POST['postcode'], "text",
GetSQLValueString($_POST['email'], "text",
GetSQLValueString($_POST['amount'], "double",
GetSQLValueString($_POST['transId'], "text",
GetSQLValueString($_POST['cartId'], "text",
GetSQLValueString($_POST['transStatus'], "text",
GetSQLValueString($_POST['testMode'], "text");
mysql_select_db($database_dancingin, $dancingin);
$Result1 = mysql_query($insertSQL, $dancingin) or die(mysql_error());
}
?>

Reply to this topic