I am using a modified version of the Coffee Store example to process signups. Strangely this code stopped working. The mySQL entry works fine. But the Authorize.net transaction doesn't.
When I hit my processing page(code below) it automatically goes to the error.php page. All the data that comes to this page is valid, btw.
But i can't get back any kind of response code when it forwards to the error.php page. Both the response code and response reason code are empty.
Any ideas why?
<?php
require_once 'coffee_store_settings.php';
// set the default timezone to use. Available since PHP 5.1
date_default_timezone_set('America/Los_Angeles');
// Prints something like: Monday 8th of August 2005 03:12:46 PM
$thisTransDate = date('Y-m-d H:i:s');
// Make a MySQL Connection
mysql_connect("localhost", "donovan", "d0n0van") or die(mysql_error());
mysql_select_db("admissions") or die(mysql_error());
// Performing SQL query
$query = 'SELECT MAX( id ) FROM hspt';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
foreach ($line as $col_value) {
$x_invoice_num = ($col_value+1);
}
}
$thisAmount = addslashes($_REQUEST['x_amount']);
$thisStudFirstName = addslashes($_REQUEST['stud_first_name']);
$thisStudLastName = addslashes($_REQUEST['stud_last_name']);
$thisStudEmail = addslashes($_REQUEST['stud_email']);
$thisGradeLevel = addslashes($_REQUEST['grade_level']);
$thisCurSchool = addslashes($_REQUEST['cur_school']);
$thisFirstName = addslashes($_REQUEST['x_first_name']);
$thisLastName = addslashes($_REQUEST['x_last_name']);
$thisPhone = addslashes($_REQUEST['x_phone']);
$thisEmail = addslashes($_REQUEST['x_email']);
$thisAddress = addslashes($_REQUEST['x_address']);
$thisCity = addslashes($_REQUEST['x_city']);
$thisZip = addslashes($_REQUEST['x_zip']);
$thisHearAbout = addslashes($_REQUEST['hear_about']);
// Insert a row of information into the table "example"
mysql_query("INSERT INTO hspt (trans_date,stud_first_name,stud_last_name,stud_email,grade_level,cur_school,par_first_name,par_last_name,par_phone,par_email,address,city,zip,hear_about) VALUES('$thisTransDate','$thisStudFirstName','$thisStudLastName','$thisStudEmail','$thisGradeLevel','$thisCurSchool','$thisFirstName','$thisLastName','$thisPhone','$thisEmail','$thisAddress','$thisCity','$thisZip','$thisHearAbout') ")
or die(mysql_error());
$transaction = new AuthorizeNetAIM;
$transaction->setSandbox(AUTHORIZENET_SANDBOX);
$transaction->setFields(
array(
'card_num' => $_POST['x_card_num'],
'exp_date' => $_POST['x_exp_date'],
'first_name' => $_POST['x_first_name'],
'last_name' => $_POST['x_last_name'],
'phone' => $_POST['x_phone'],
'email' => $_POST['x_email'],
'address' => $_POST['x_address'],
'city' => $_POST['x_city'],
'zip' => $_POST['x_zip'],
'card_code' => $_POST['x_card_code'],
'amount' => $_POST['x_amount'],
'invoice_num' => $_POST['x_invoice_num'],
'description' => $_POST['x_description']
)
);
$response = $transaction->authorizeAndCapture();
if ($response->approved) {
header('Location: thank_you_page.php');
} else {
header('Location: error_page.php?response_reason_code='.$response->response_reason_code.'&response_code='.$response->response_code.'&response_reason_text=' .$response->response_reason_text);
}
?>
08-26-2015 11:27 AM
To see what I am referring tohit signup on this page:
08-26-2015 03:49 PM