This topic is locked
[SOLVED]

 Send Email

2/14/2014 4:15:08 AM
PHPRunner General questions
Y
YCH author

[size="2"]I have a _add.php page with some fields: fullname, email, subject message.

I have also inserted a custom button.
This button's Client Before tab=

empty

[/size]

[size="2"][size="2"]The button's Server tab has this code=

$from=$values["Email"];

$to="smo@swh.com";

$msg=$values["Message"];

$subject=$values["Subject"];
$ret=runnermail(array('to' => $to, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];
[/size][/size][size="2"][size="2"][size="2"][size="2"]The button's Client After tab=

empty

[/size][/size][/size][/size]


[size="2"][size="2"][size="2"][size="2"][size="2"][size="2"][size="2"][size="2"]What do I miss to have this code functioning from a click on the Custom button on my _add.php page?_
[/size][/size][/size]By the way, u[/size]sing the same Server tab code on the BeforeRecordAdded or AfterRecordAdded event when clicking on the standard Save button does the job.
Any advice is appreciated.

Yves
[/size][/size][/size][/size]

Sergey Kornilov admin 2/14/2014

Most likely the issue is that $values array is not available in button's Server code.
Check this article that explains how you can access field values:

http://xlinesoft.com/phprunner/docs/inserting_button.htm

Y
YCH author 2/14/2014

Sergey,
I should have read this : passing the field values with $result and $params did it.

Thank you.

A
Anapolis 2/17/2014

I am very happy you asked this question when you did that prompted me to look at Sergey's examples.
This is going to come in very, very handy for the latest project now underway!