This topic is locked
[SOLVED]

 If statement syntax help

10/28/2019 6:44:52 AM
PHPRunner General questions
B
bcritchley author

I have the 2 If statements below added to the "After Record Update" section of my project, but both seem to execute if either one is true and I am not certain on ending the statements properly.
if ($values["Date_Completed"]!=$oldvalues["Date_Completed"]) {

//** Send email with new data ****
$email=$values['Requestor_Email'];

$from="my.email@greececsd.org";

$msg="The request you submitted below has been completed"."\r\n\n";

$subject="We have completed Courier Request number".$values['Request_Number'];
$msg.= "Request Number: ".$values['Request_Number']."\r\n";

$msg.= "Customer: ".$values['Requestor_Name']."\r\n";

$msg.= "Customers Email: ".$values['Requestor_Email']."\r\n";

$msg.= "Latest Pickup Date: ".$values['Latest_Pickup_Date']."\r\n";

$msg.= "Date Completed: ".$values['Date_Completed']."\r\n";

$msg.= "Completed by: ".$values['Completed_By']."\r\n";

$msg.= "Pickup from: ".$values['Pickup_Location']."\r\n";

$msg.= "Deliver to: ".$values['Destination_Location']."\r\n";

$msg.= "Request: ".$values['Details']."\r\n";
$ret=runner_mail(array('to' => $email, 'bcc' => 'my.email@greececsd.org', 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];
}
if ($values["Custodial_Email"]!=$oldvalues["Custodial_Email"]) {
//** Send email with new data ****
$email=$values['Custodial_Email'];

$from="my.email@greececsd.org";

$subject="Central Stores is requesting your assistance";
$msg.= "Are you able to assist Central Stores with the following. "."\r\n\n";

$msg.= $values['Custodial_Notes']."\r\n";

$msg.= "Request Number: ".$values['Request_Number']."\r\n";

$msg.= "Customer: ".$values['Requestor_Name']."\r\n";

$msg.= "Latest Pickup Date: ".$values['Latest_Pickup_Date']."\r\n";

$msg.= "Pickup from: ".$values['Pickup_Location']."\r\n";

$msg.= "Deliver to: ".$values['Destination_Location']."\r\n";

$msg.= "Request: ".$values['Details']."\r\n";
$ret=runner_mail(array('to' => $email, 'bcc' => 'my.email@greececsd.org', 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];
}
// Place event code here.

// Use "Add Action" button to add code snippets.

Sergey Kornilov admin 10/28/2019

The general structure of your code looks correct. If both emails are being sent that means both conditions were met.