I'm trying grab and insert into a mysql database table some users info when they sign up using ccbill. here's what i'm using....can someone direct me to some sources or help fix this. I'm willing to pay someone who can write one that works.
basically....i'm trying to do a postback with ccbill.
PHP Code:
<?php
### LISTING OF ipn.php
define ("DBHOST", "localhost");
define ("DBNAME", "mydb");
define ("DBUSER", "myuser");
define ("DBPASS", "mypass");
### CONNECT TO THE DATABASE
function DatabaseConnect() {
if (!($mylink = mysql_connect(DBHOST, DBUSER, DBPASS))) {
echo mysql_error();
exit;
} //fi
mysql_select_db(DBNAME) or die(mysql_error());
} // end function
DatabaseConnect(); // this will automatically connect us
// below supported vals that CC Bill posts to us, this list is exhaustive.. but
// without notify_version and verify_sign NOTE: if in is not in this array, it
// is not going in the database.
$ccbill_vals = array("customer_fname", "customer_lname", "email",
"username", "password", "price", "start_date", "phone_number"
);
// build insert statement
while (list ($key, $value) = each ($HTTP_POST_VARS)) {
if (in_array ($key, $ccbill_vals)) {
if (is_numeric($value)) {
$addtosql .= " $key=$value,";
} else {
$newval = urlencode($value);
$topost .= "&$key=$newval"; //used later in reposting
$value = addslashes($value);
$addtosql .= " $key='$value',";
} //fi
} //fi
$entirepost .= "[$key]='$value',";
} //wend
$entirepost = addslashes($entirepost); // just in case..
$addtosql = substr("$addtosql", 0, -1).";"; //chop trailing "," replace with ";"
$sql1 = "
INSERT INTO users
SET date=now(), entirepost='$entirepost',". $addtosql;
mysql_db_query(DBNAME, $sql1) or die($sql1);
} //fi
### END LISTING OF ipn.php
?>
Last edited by 0beron; 08-13-2005 at 06:14 PM..
|