I am trying to send 2 different emails after the user edits the order record - one to the admin and one to an email specified in the form. I need to send it after the edit because that is where they confirm the order after seeing the calculated total. I want it to send the data for all fields in the record. The field in the form that specifies the email address is receipt_email. The current code produces an error.
Here is the code I have:
//** Custom code ****
// put your custom code here
global $strTableName, $conn;
$strSQLExists = "select * from _orders where beneficiary_id='".$_SESSION[$strTableName."_masterkey1"]."'";
$rsExists = db_query($strSQLExists,$conn);
$data=db_fetch_array($rsExists);
if($data)
{
$_SESSION["order_no"] = $data["order_no"];
}
}
// function BeforeEdit
function AfterEdit()
{
//** Send email with new data ****
$email="email@test.com";
$message="";
$subject="New order on domain.com";
foreach($evalues as $field=>$value)
$message.= $field." : ".$evalue."\r\n";
mail($email, $subject, $message);
//** Send email with new data ****
$message="";
$subject="Your order is being processed on domain.com";
//select receipt_email from _orders
$str = "select receipt_email from _orders where order_no = '".$_SESSION["order_no"]."'";
$rs = db_query($str,$conn);
$data = db_fetch_array($rs);
$receipt_email = $data["email"];
$email=$receipt_email;
foreach($evalues as $field=>$evalue)
$message.= $field." : ".$evalue."\r\n";
mail($email, $subject, $message);
}
// function AfterEdit
When updating the record, I receive the following error:
PHP error happened
Technical information
Error type 8
Error description Undefined variable: evalues
Any help on this would be appreciated.
Thanks,
Janet