[insert_php]
session_start();
include_once(“config/connection.php”);

//include the configuration file
include_once(“config/config.php”);
include_once(“functions/functions.php”);
$connection = new Connection($dbServer, $dbCatalog, $dbUser, $dbPassword);
$connection->Open();
$success=false;
if($_POST[‘gtpay_tranx_id’] !=””){
switch($_POST[‘gtpay_tranx_curr’]){
case ‘844’:
$sign=’$’;
break;
default:
$sign=’N’;
}
$code=preg_replace(‘/\s+/’, ”, $_POST[‘gtpay_tranx_status_code’]);
if($code ==”00″){
$query = “SELECT d.Amount,u.Firstname,u.Surname,u.Email FROM `tbl_donation` d left join tbl_user u on d.UserID=u.UserID where d.ReferenceNo='”.$_POST[‘gtpay_tranx_id’].”‘”;
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$fname=$row[‘Firstname’];
$lname=$row[‘Surname’];
$email=$row[‘Email’];
$amount=$row[‘Amount’];

}
$query = “update `tbl_donation` set Rspdesc='”.$_POST[‘gtpay_tranx_status_msg’].”‘,Rspcode='”.$_POST[‘gtpay_tranx_status_code’].”‘, Status=’Successful’ where ReferenceNo='”.$_POST[‘gtpay_tranx_id’].”‘”;
mysql_query($query);
$to = $email;
$subject = “EMHF Donations”;
$tranid=$_POST[‘gtpay_tranx_id’];
$txt= ‘Dear ‘.$fname.’ ‘.$lname.’,’ .”\r\n”;
$txt .= ‘Your donation of ‘.$sign.’ ‘.number_format($amount, 2, ‘.’, ‘,’).’ to EMHF was successful.’ .”\r\n”;
$txt .= ‘Your payment reference number is ‘.$tranid .”\r\n”;
$txt .= ‘Please contact info@emhfgirlshome.com for any enquiries.’ .”\r\n”;
$txt .= ‘the Lord bless you for your seed .James 1v27’ .”\r\n”;
$txt .= ‘Yours faithfully,’ .”\r\n”;
$txt .= ‘EMHF Team’ .”\r\n”;
//echo $txt;
$headers = “From: info@emhfgirlshome.com”;
$headers .= ‘Cc: info@emhfgirlshome.com’ . “\r\n”;
$headers .= ‘Cc: folasoyebo@gmail.com’ . “\r\n”;
mail($to,$subject,$txt,$headers);
$pagetitle=’Payment Successful‘;
$message= ‘

Thank you very much for your donation.

“the Lord bless you for your seed .James 1v27”

An email has been sent to you with your reference number (‘.$_POST[‘gtpay_tranx_id’].’) for your records.

Please click here to continue browsing the site.

‘;
$success=true;
}
}else{
$success=false;
}
if($success==false){
$query = “update `tbl_donation` set Rspdesc='”.$_POST[‘gtpay_tranx_status_msg’].”‘,Rspcode='”.$_POST[‘gtpay_tranx_status_code’].”‘,Status=’Unsuccessful’ where ReferenceNo='”.$_POST[‘gtpay_tranx_id’].”‘”;
mysql_query($query);
$message=’

Unfortunately, we could not process your transaction.

Reason: ‘.$_POST[‘gtpay_tranx_status_msg’].’

Please quote the reference number: ‘.$_POST[‘gtpay_tranx_id’].’ to query this transaction.

We appreciate your wanting to contribute to EMHF, please try again by clicking here

‘;
$pagetitle=’Payment Unsuccessful‘;
}

?>

Close();
[/insert_php]