This topic is locked

simple e-mail

7/31/2012 12:52:09 PM
PHPRunner General questions
R
Rapacious author

I'm trying to get an e-mail sent based on a field being updated. For the past 6 months I've been using the command below:
if ($oldvalues["PP_S35_DATE"] != $values["PP_S35_DATE"]) {

// ** Send simple email ****

$email="jbarreras@srdcommercial.com";

$from="contact@saundersrealestate.com";

$msg="Price Change ".$values["Marketing Title"]." listing. ".$values["Listing Agent"]." has updated the price. Please begin the Price Change Protocol";

$subject="Price Change: ".$values["Marketing Title"];

$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];

}

And it's been working great. So at this point, I'm trying to make it to send an e-mail based on another field being updated. My first guess was to just add another if e-mail statement like below:
if ($oldvalues["PP_S35_DATE"] != $values["PP_S35_DATE"]) {

// ** Send simple email ****

$email="jbarreras@srdcommercial.com";

$from="contact@saundersrealestate.com";

$msg="Price Change ".$values["Marketing Title"]." listing. ".$values["Listing Agent"]." has updated the price. Please begin the Price Change Protocol";

$subject="Price Change: ".$values["Marketing Title"];

$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];

}
if ($oldvalues["PP_S2_DATE"] != $values["PP_S2_DATE"]) {

// ** Send simple email ****

$email="jbarreras@srdcommercial.com";

$from="contact@saundersrealestate.com";

$msg="Please begin to process the ".$values["Marketing Title"]." listing. ".$values["Listing Agent"]." has completed the Listing Inofrmation Sheet and the project is now ready to begin the marketing process";

$subject="New Listing: ".$values["Marketing Title"];

$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];

}
But it doesn't work. With the above changes, I get both e-mails regardless of if I updated either field or not.
I've also tried elseif for the 2nd if statement to no avail.
I'm baffled please help.

C
cgphp 7/31/2012

Before the if statements, echo the result of the comparison of the two values:

echo "CMP 1:" . strcmp($oldvalues["PP_S35_DATE"], $values["PP_S35_DATE"]);

echo "<br/>";

echo "CMP 2:" . strcmp($oldvalues["PP_S2_DATE"], $values["PP_S2_DATE"]);

exit();



strcmp returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.

R
Rapacious author 8/1/2012

Thanks for the reply Cristian. I went ahead and added the echo code before my "if" statements and when I changed my field PP_S35_DATE, I hit save and below is the error that showed up on my screen. No e-mail had been sent. I've tried to find information on how to use echo further in the capacity I'm looking for but I haven't been able to find what I need.
CMP 1:1

CMP 2:-9

C
cgphp 8/1/2012

No email was sent because the exit() command stopped the execution. The oldvalue and the current value are always different and both email are sent.