Hey guys,

I have a problem, my process_transaction.php page was working fine before I added some code to it....but I need that code to work.

I added an if statement that should send an email to my client's once my process_transaction.php has determined whether or not the payment has been approved. Here is the whole code for that page:

<?php
	include_once("gatewayapi/inc_gatewayapi.php");
	
	$transaction = new GatewayTransaction($_REQUEST, $_SERVER['REMOTE_ADDR']);
	
	if($transaction->ProcessTransaction($responseString, $errorCode))
	{
		$response = new GatewayResponse($responseString, $GatewaySettings['delim_char']);
		
		// Check MD5 Hash Value
		//
		 if($GatewaySettings['MD5Hash'] 
				&& !$response->VerifyMD5Hash($GatewaySettings['MD5Hash'],
														$transaction->username,
														$transaction->amount))
			{
				header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($transaction->GetErrorString("INVALID_MD5HASH")));
				exit();
			}
		 	

		
if($response->IsApproved()) {
	$eol = "\r\n";
	$to = "donation@myclient.org"; //the recipient
	$subject = "Donation Information"; // the subject
	$message = "<html>
<head>
<title>Donation Information</title>
</head>
<body>
<p>Donation Information</p>
<table>
<tr>
<th>Donation Amount:</th>
</tr>
<tr>
<td><?php echo $_GET["amount"]; ?></td>
</tr>
<tr>
<th>Designation:</th>
</tr>
<tr>
<td><?php echo $_GET["Desc"]; ?></td>
</tr>
</table>
<p>Billing Information</p>
<table>
<tr>
<th>First Name:</th>
<th>Last Name:</th>
</tr>
<tr>
<td><?php echo $_GET["first_name"]; ?></td>
<td><?php echo $_GET["last_name"]; ?></td>
</tr>
<tr>
<th>Spouse Name:</th>
</tr>
<tr>
<td><?php echo $_GET["Spouse"]; ?></td>
</tr>
<tr>
<th>Address:</th>
</tr>
<tr>
<td><?php echo $_GET["address"]; ?></td>
</tr>
<tr>
<th>City:</th>
</tr>
<tr>
<td><?php echo $_GET["city"]; ?></td>
</tr>
<tr>
<th>State:</th>
</tr>
<tr>
<td><?php echo $_GET["state"]; ?></td>
</tr>
<tr>
<th>Zip Code:</th>
</tr>
<tr>
<td><?php echo $_GET["zip"]; ?></td>
</tr>
<tr>
<th>Country:</th>
</tr>
<tr>
<td><?php echo $_GET["country"]; ?></td>
</tr>
<tr>
<th>Phone Number:</th>
</tr>
<tr>
<td><?php echo $_GET["phone"]; ?></td>
</tr>
<tr>
<th>Email Address:</th>
</tr>
<tr>
<td><?php echo $_GET["email"]; ?></td>
</tr>
<tr>
<th>Credit Card:</th>
</tr>
<tr>
<td><?php echo $cc_number = "XXXX-XXXX-XXXX-" . substr($cc_number,-4,4); ?></td>
</tr>
</table>

<p>Shipping Information</p>
<table>
<tr>
<th>First Name:</th>
<th>Last Name:</th>
</tr>
<tr>
<td><?php echo $_GET["shipping_first_name"]; ?></td>
<td><?php echo $_GET["shipping_last_name"]; ?></td>
</tr>
<tr>
<th>Address:</th>
</tr>
<tr>
<td><?php echo $_GET["shipping_address"]; ?></td>
</tr>
<tr>
<th>City:</th>
</tr>
<tr>
<td><?php echo $_GET["shipping_city"]; ?></td>
</tr>
<tr>
<th>State:</th>
</tr>
<tr>
<td><?php echo $_GET["shipping_state"]; ?></td>
</tr>
<tr>
<th>Zip Code:</th>
</tr>
<tr>
<td><?php echo $_GET["shipping_zip"]; ?></td>
</tr>
<tr>
<th>Country:</th>
</tr>
<tr>
<td><?php echo $_GET["shipping_country"]; ?></td>
</tr>
</table>

<p>Gift of Love</p>
<table>
<tr>
<th>This gift is:</th>
</tr>
<tr>
<td><?php echo $_GET["GiftDesc1"]; ?></td>
</tr>
<tr>
<th>Is this a pet?</th>
</tr>
<tr>
<td><?php echo $_GET["IsThisaPet"]; ?></td>
</tr>
<tr>
<th>If a pet what kind:</th>
</tr>
<tr>
<td><?php echo $_GET["TypeofPet"]; ?></td>
</tr>
<tr>
<th>Name:</th>
</tr>
<tr>
<td><?php echo $_GET["GiftDesc2"]; ?></td>
</tr>
<tr>
<th>Address:</th>
</tr>
<tr>
<td><?php echo $_GET["GOLAddress"]; ?></td>
</tr>
<tr>
<th>City:</th>
</tr>
<tr>
<td><?php echo $_GET["GOLCity"]; ?></td>
</tr>
<tr>
<th>State:</th>
</tr>
<tr>
<td><?php echo $_GET["GOLState"]; ?></td>
</tr>
<tr>
<th>Zip:</th>
</tr>
<tr>
<td><?php echo $_GET["GOLZip"]; ?></td>
</tr>
<tr>
<th>Country:</th>
</tr>
<tr>
<td><?php echo $_GET["GOLCountry"]; ?></td>
</tr>
</table>

</body>
</html>

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; // The donation message


	$headers = "From: New Donation  <no-reply@mysite.org>$eol";
	
	if(@mail($to, $subject, $message, $headers)) {
		header("Location: " . $GatewaySettings['PaymentApprovedPage']);
	}
}

else {
	header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($response->GetField("ResponseReasonText")));
}

else {
	header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($transaction->GetErrorString($errorCode)));
}
?>

Any ideas how I can fix this or any suggestions on how I can make it to where this works. It should check to see if($response->IsApproved and if it was then it will send an email.

It will work if I take out the HTML email but I need it to send my client these forms fields. Please help, thank you : )

Hi,
Try this, u placed an misplaced else.

<?php
include_once("gatewayapi/inc_gatewayapi.php");
$transaction = new GatewayTransaction($_REQUEST, $_SERVER['REMOTE_ADDR']);
if($transaction->ProcessTransaction($responseString, $errorCode))
{
	$response = new GatewayResponse($responseString, $GatewaySettings['delim_char']);
	if($GatewaySettings['MD5Hash']&& !$response->VerifyMD5Hash($GatewaySettings['MD5Hash'],$transaction->username,$transaction->amount))
	{
		header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($transaction->GetErrorString("INVALID_MD5HASH")));
		exit();
	}
	if($response->IsApproved()) 
	{
		$eol = "\r\n";
		$to = "donation@myclient.org"; //the recipient
		$subject = "Donation Information"; // the subject
		$message = "";
	?>	
		<html>
			<head>
				<title>Donation Information</title>
			</head>
		<body>
			<p>Donation Information</p>
				<table>
						<tr>
							<th>Donation Amount:</th>
						</tr>
						<tr>
							<td><?php echo($_GET['amount']); ?></td>
						</tr>
						<tr>
							<th>Designation:</th>
						</tr>
						<tr>
							<td><?php echo $_GET["Desc"]; ?></td>
						</tr>
				</table>
	<p>Billing Information</p>
	<table>
		<tr>
			<th>First Name:</th>
			<th>Last Name:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["first_name"]; ?></td>
			<td><?php echo $_GET["last_name"]; ?></td>
		</tr>
		<tr>
		<th>Spouse Name:</th>
		</tr>
		<tr>	
			<td><?php echo $_GET["Spouse"]; ?></td>
		</tr>
		<tr>
			<th>Address:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["address"]; ?></td>
		</tr>
		<tr>
			<th>City:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["city"]; ?></td>
		</tr>
		<tr>
			<th>State:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["state"]; ?></td>
		</tr>	
		<tr>
			<th>Zip Code:</th>
		</tr>
		<tr>		
			<td><?php echo $_GET["zip"]; ?></td>
		</tr>
		<tr>
			<th>Country:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["country"]; ?></td>
		</tr>
		<tr>
			<th>Phone Number:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["phone"]; ?></td>
		</tr>
		<tr>
			<th>Email Address:</th>		
		</tr>
		<tr>
			<td><?php echo $_GET["email"]; ?></td>
		</tr>
		<tr>
			<th>Credit Card:</th>
		</tr>
		<tr>
			<td><?php echo $cc_number = "XXXX-XXXX-XXXX-" . substr($cc_number,-4,4); ?></td>
		</tr>
	</table>
	<p>Shipping Information</p>
	<table>
		<tr>
			<th>First Name:</th>
			<th>Last Name:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["shipping_first_name"]; ?></td>
			<td><?php echo $_GET["shipping_last_name"]; ?></td>
		</tr>
		<tr>
			<th>Address:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["shipping_address"]; ?></td>
		</tr>
		<tr>
			<th>City:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["shipping_city"]; ?></td>
		</tr>
		<tr>
			<th>State:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["shipping_state"]; ?></td>
		</tr>
		<tr>
			<th>Zip Code:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["shipping_zip"]; ?></td>
		</tr>
		<tr>
			<th>Country:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["shipping_country"]; ?></td>
		</tr>
	</table>
	<p>Gift of Love</p>
	<table>
		<tr>
			<th>This gift is:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GiftDesc1"]; ?></td>
		</tr>
		<tr>
			<th>Is this a pet?</th>
		</tr>
		<tr>
			<td><?php echo $_GET["IsThisaPet"]; ?></td>
		</tr>
		<tr>
			<th>If a pet what kind:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["TypeofPet"]; ?></td>
		</tr>
		<tr>
			<th>Name:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GiftDesc2"]; ?></td>
		</tr>
		<tr>
			<th>Address:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GOLAddress"]; ?></td>
		</tr>
		<tr>
			<th>City:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GOLCity"]; ?></td>
		</tr>
		<tr>
			<th>State:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GOLState"]; ?></td>
		</tr>
		<tr>
			<th>Zip:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GOLZip"]; ?></td>
		</tr>
		<tr>
			<th>Country:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GOLCountry"]; ?></td>
		</tr>
	</table>
	</body>
	</html>
<?PHP
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; // The donation message
$headers = "From: New Donation <no-reply@mysite.org>$eol";
		if(@mail($to, $subject, $message, $headers)) 
		{		
			header("Location: " . $GatewaySettings['PaymentApprovedPage']);
		}
		else{
		header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($response->GetField("ResponseReasonText")));
		}
	}
	
else {
header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($transaction->GetErrorString($errorCode)));
}
}
?>

Hmmm....I tried this and now it does not give me an error like error on line 38. But now it just goes to /process_transaction.php and is on a blank page. It should go to my approved or denied page. Thank you for the quick response and you helped get rid of the error but do you have any other suggestions?

Hi,
Try this, u placed an misplaced else.

<?php
include_once("gatewayapi/inc_gatewayapi.php");
$transaction = new GatewayTransaction($_REQUEST, $_SERVER['REMOTE_ADDR']);
if($transaction->ProcessTransaction($responseString, $errorCode))
{
	$response = new GatewayResponse($responseString, $GatewaySettings['delim_char']);
	if($GatewaySettings['MD5Hash']&& !$response->VerifyMD5Hash($GatewaySettings['MD5Hash'],$transaction->username,$transaction->amount))
	{
		header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($transaction->GetErrorString("INVALID_MD5HASH")));
		exit();
	}
	if($response->IsApproved()) 
	{
		$eol = "\r\n";
		$to = "donation@myclient.org"; //the recipient
		$subject = "Donation Information"; // the subject
		$message = "";
	?>	
		<html>
			<head>
				<title>Donation Information</title>
			</head>
		<body>
			<p>Donation Information</p>
				<table>
						<tr>
							<th>Donation Amount:</th>
						</tr>
						<tr>
							<td><?php echo($_GET['amount']); ?></td>
						</tr>
						<tr>
							<th>Designation:</th>
						</tr>
						<tr>
							<td><?php echo $_GET["Desc"]; ?></td>
						</tr>
				</table>
	<p>Billing Information</p>
	<table>
		<tr>
			<th>First Name:</th>
			<th>Last Name:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["first_name"]; ?></td>
			<td><?php echo $_GET["last_name"]; ?></td>
		</tr>
		<tr>
		<th>Spouse Name:</th>
		</tr>
		<tr>	
			<td><?php echo $_GET["Spouse"]; ?></td>
		</tr>
		<tr>
			<th>Address:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["address"]; ?></td>
		</tr>
		<tr>
			<th>City:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["city"]; ?></td>
		</tr>
		<tr>
			<th>State:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["state"]; ?></td>
		</tr>	
		<tr>
			<th>Zip Code:</th>
		</tr>
		<tr>		
			<td><?php echo $_GET["zip"]; ?></td>
		</tr>
		<tr>
			<th>Country:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["country"]; ?></td>
		</tr>
		<tr>
			<th>Phone Number:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["phone"]; ?></td>
		</tr>
		<tr>
			<th>Email Address:</th>		
		</tr>
		<tr>
			<td><?php echo $_GET["email"]; ?></td>
		</tr>
		<tr>
			<th>Credit Card:</th>
		</tr>
		<tr>
			<td><?php echo $cc_number = "XXXX-XXXX-XXXX-" . substr($cc_number,-4,4); ?></td>
		</tr>
	</table>
	<p>Shipping Information</p>
	<table>
		<tr>
			<th>First Name:</th>
			<th>Last Name:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["shipping_first_name"]; ?></td>
			<td><?php echo $_GET["shipping_last_name"]; ?></td>
		</tr>
		<tr>
			<th>Address:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["shipping_address"]; ?></td>
		</tr>
		<tr>
			<th>City:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["shipping_city"]; ?></td>
		</tr>
		<tr>
			<th>State:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["shipping_state"]; ?></td>
		</tr>
		<tr>
			<th>Zip Code:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["shipping_zip"]; ?></td>
		</tr>
		<tr>
			<th>Country:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["shipping_country"]; ?></td>
		</tr>
	</table>
	<p>Gift of Love</p>
	<table>
		<tr>
			<th>This gift is:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GiftDesc1"]; ?></td>
		</tr>
		<tr>
			<th>Is this a pet?</th>
		</tr>
		<tr>
			<td><?php echo $_GET["IsThisaPet"]; ?></td>
		</tr>
		<tr>
			<th>If a pet what kind:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["TypeofPet"]; ?></td>
		</tr>
		<tr>
			<th>Name:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GiftDesc2"]; ?></td>
		</tr>
		<tr>
			<th>Address:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GOLAddress"]; ?></td>
		</tr>
		<tr>
			<th>City:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GOLCity"]; ?></td>
		</tr>
		<tr>
			<th>State:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GOLState"]; ?></td>
		</tr>
		<tr>
			<th>Zip:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GOLZip"]; ?></td>
		</tr>
		<tr>
			<th>Country:</th>
		</tr>
		<tr>
			<td><?php echo $_GET["GOLCountry"]; ?></td>
		</tr>
	</table>
	</body>
	</html>
<?PHP
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; // The donation message
$headers = "From: New Donation <no-reply@mysite.org>$eol";
		if(@mail($to, $subject, $message, $headers)) 
		{		
			header("Location: " . $GatewaySettings['PaymentApprovedPage']);
		}
		else{
		header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($response->GetField("ResponseReasonText")));
		}
	}
	
else {
header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($transaction->GetErrorString($errorCode)));
}
}
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.