I am wanting to send an email receipt to a user after they submit to edit their order.
I am using PHPRunner 4.0 and have access to 4.1
The MySQL database is running on Apache version 1.3.37 (Unix) with PHP version 4.4.4 and MySQL version 4.1.22-standard
Here are my issues:
- I need to pull up their email address from a field in the _orders table called receipt_email on the edit record page. How do I draw this email address for the email recipient?
- I need to only send certain fields that I specify in the code. I do not want to send all fields (some would be a security risk) or only new fields (I need other fields that wouldn't be changed on the edit page but do exist in the record). If I hard code the email recipient, using the code listed below, the email sends but any part of the message that is supposed to be a value from a database record field is blank in the email (see email at the end of this post). What did I do wrong in this code? I've tested several variations trying to get this to work and I'm stuck.
I have set the Session variable for order_no as an After Add event. The Add page then redirects to the edit page where they confirm the total amount (calculated as an after add event) and submit the order.
I need some assistance on this code to make this work.
Thanks a bunch,
Janet
CODE
[codebox]//** Send email to member ****
global $conn,$values;
$str = "select * from _orders where order_no='".$_SESSION["order_no"]."'";
$rs = db_query($str,$conn);
$data = db_fetch_array($rs);
{
$email=hardcoded_email@domain.com;
$subject="Receipt for your order on domain.com";
$headers = "From: test@test.com";
$message= "Thank you for your order on domain.com." . "\n\n";
$message.= "Here is your receipt information." . "\n\n";
$message.= "Order Number: ".$values["order_no"]."\n";
$message.= "Order Date: ".$values["order_date"]."\n";
$message.= "Member: ".$values["member_firstname"]." ".$values["member_lastname"]."\n";
$message.= "Beneficiary: ".$values["beneficiary_firstname"]." ".$values["beneficiary_lastname"]."\n\n";
$message.= "Sent Amount: ".$values["sent_amount"]."\n";
$message.= "Flat Transaction Fee: ".$values["transactionfee_flat"]."\n";
$message.= "Percentage Transaction Fee: ".$values["transactionfee_percent"]."\n";
$message.= "Total: ".$values["total"]."\n\n";
$message.= "Sensitive order information has been omitted for security purposes. Please login to your account for full order information." . "\n\n";
mail($email, $subject, $message, $headers);
}
[/codebox]
Here is the email I receive:
EMAIL
Thank you for your order on domain.com.
Here is your receipt information.
Order Number:
Order Date:
Member:
Beneficiary:
Sent Amount:
Flat Transaction Fee:
Percentage Transaction Fee:
Total:
Sensitive order information has been omitted for security purposes. Please login to your account for full order information.