This topic is locked
[SOLVED]

 Reading A Specific Field Value

5/3/2013 1:04:48 AM
PHPRunner General questions
T
TKirchner author

Hello,
i have some trouble finding the right function to solve my problem.
Explanation:
I want phprunner to send an email to person X when the value in a specific field is "1" and want it to send an email to person Y when the value in the same specific field is "2" for example.
Im using a drop down menu for this field, so as soon i have a database entry with the the value 1 or 2 in that field the EXISTS function does not longer work because the values are saved for that field.
Hope my explanation was understandable and you will have a solution for me.
Greetings
Tim Kirchner

C
cgphp 5/3/2013

Post your code. In which event is the code?

T
TKirchner author 5/3/2013

The code should be placed in the After Add and After Edit function, basicly for now im just using the sample code snippet from phprunner since im not a programmer and have very little knowledge about how things work:
//** Send email with new data ****

$email="test@test.com";

$from="admin@test.com";

$msg="";

$subject="New data record";
foreach($values as $field=>$value)

{

if(!IsBinaryType(GetFieldType($field)))

$msg.= $field." : ".$value."\r\n";

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

if(!$ret["mailed"])

echo $ret["message"];

C
cgphp 5/3/2013
$from="admin@test.com";

$msg="Hello world!";

$subject="New data record";
if($values['specific_field_name'] == 1)

{

$email="x@x.com";

}

else

{

$email="y@y.com";

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

if(!$ret["mailed"])

{

echo $ret["errors"][0]["description"];

}
T
TKirchner author 5/6/2013


$from="admin@test.com";

$msg="Hello world!";

$subject="New data record";
if($values['specific_field_name'] == 1)

{

$email="x@x.com";

}

else

{

$email="y@y.com";

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

if(!$ret["mailed"])

{

echo $ret["errors"][0]["description"];

}



That helped me a lot, thank you for this solution!
Greetings
Tim Kirchner