Forums

Send in email a php output

marcozeus 03 Jun, 2013
Hi,
I'm a newbie about Chronoforms and I'm sorry if my question is very simple, but I need your help.
I created a contact form (name, last name, ecc.) but I put a custom element (html/php) above all that contains a php script with a while loop into the db. The output is correct and the form is like perfect but I don't know the way to send the output in email together the other data (from the various form fields).
Can anyone help me, please?
GreyHead 04 Jun, 2013
Hi marcozeus,

You can either add PHP to the email template directly; or you can add the output to the $form->data array and then use the array key in the form {key_name} in the template.

Bob
marcozeus 04 Jun, 2013
Hi Bob,
first of all thanks for your answer.
I tried to add the PHP script into the email template directly but the script contains both html and php (connection to mysql, query and while loop to echo that query); the result is only html, without any php output. It's clear that I'm wrong... but the php script is correct in a standard page.
Unfortunately, I don't understand the second solution you provided; could you explain it to me?
GreyHead 05 Jun, 2013
Hi marcozeus,

What is the script that you are using?

You should be able to use PHP in the Email template provided that you enclose the script in <?php ?> tags and the Email rich text editor is off so you are adding the code in the plain textarea.

The other way is to use a Custom Code element before the Email and add something like this
<?php
. . . // your code here
$form->data['my_code_output'] = $???;
?>
Then put {my_code_output} in the email template.

Bob
This topic is locked and no more replies can be posted.