This topic is locked

Send email after edit

10/17/2007 10:51:23 AM
PHPRunner General questions
J
jetacera author

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

Sergey Kornilov admin 10/17/2007

You cannot use $evalues array because it's not defined.
What version of PHPRunner do you use?

Version 4.1 allows you to access both old and new record values.

J
jetacera author 10/17/2007

I'm using phprunner version 4.0 on this project since I did most of the work on it in July before verson 4.1 came out. I have version 4.1. If I open up this project using 4.1 will it keep all the html I modified in the visual editor? I wouldn't want to have to redo all of that if it wasn't necessary. The only thing I need to do on this project is get it to send the 2 emails after the record is edited.
I'm open to solutions using either version, though I would prefer to use 4.0 if at all possible. How to I define the evalues array? What would the correct code be?
Thanks a lot!
Janet <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=22339&image=1&table=forumreplies' class='bbc_emoticon' alt=':blink:' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=22339&image=2&table=forumreplies' class='bbc_emoticon' alt=':unsure:' />

J
Jane 10/18/2007

Janet,
to declare $evalues array use this code:

global $evalues;