Problem recieving result to both change db and send mail.
Posted: Fri May 16, 2008 1:12 pm
Hi i have a problem with my php and mySql code. Once a transaction is completed and successfull it will return the result 00 but i can't seem to change the status of the order to paid in the db and send myself an email to let me know of the order. Can you please help. The code is below:
Code: Select all
if ($result == "00") {
// check that the invoice has not been previously processed
$sql = "SELECT od_status
FROM tbl_order
WHERE od_id = {$_POST['ORDER_ID']}";
$result = dbQuery($sql);
// if no invoice with such number is found, exit
if (dbNumRows($result) != "00") {
exit;
} else {
$row = dbFetchAssoc($result);
$_SESSION['mydatabase_od_id'] = $row['od_id'];
// process this order only if the status is still 'New'
if ($row['od_status'] !== 'New') {
exit;
} else {
// ok, so this order looks perfectly okay
// now we can update the order status to 'Paid'
// update the memo too
$sql = "UPDATE tbl_order
SET od_status = 'Paid', od_memo = '$memo', od_last_update = NOW()
WHERE od_id = '{$row['od_id']}'";
$result = dbQuery($sql);
}
}
/* --------------------------------------------------------------
Send notification email to yourself.
*/
if ($shopConfig['sendOrderEmail'] == 'y') {
$subject = "[New Order] " . $_SESSION['orderId'];
$email = $shopConfig['email'];
$message = "\n A customer has sent you a new order. Follow the link for the order details \n http://"
. $_SERVER['HTTP_HOST'] . '/my/orders/index.php?view=detail&oid='
. $_SESSION['orderId']
. "\n If you cannot open the link or are having problems logging in to your account please contact the Site Administrator. \n" ;
mail($email, $subject, $message, "From: $email\r\nReturn-path: $email");
}
?>
Thank you
<br/><br/>
To continue browsing please <a href="http://yourdomain.com"><b><u>click here</u></b></a>
<br/><br/>
<?
} else {
?>