Use PHP syntax to create a dynamic e-mail

Jannick 14 Feb, 2011
Dear all,

I would like the response e-mail of my Chonoform-questionnaire to contain the result of some calculations. For example: my questionnaire will contain response items {length} and {weight} and I would like to present a BMI (weight divided by length squared) in my response e-mail.

I have already figured out that I should use PHP-syntax to configure the e-mail HTML-code and I have also found some basic example-syntaxes for performing PHP-calculations. However, can anyone explain to me how I can use the responses from the questionnaire in PHP? For example, consider the following PHP-syntax. What should I put in instead of {weight} and {length}?
<?php
 
   $value1 = {weight}; 
   $value2 = {length}; 
 
   $bmi = $value1 / ($value2*$value2); 

   echo $bmi; 

?>
GreyHead 14 Feb, 2011
Hi jannick,

You can't use the {input_name} syntax with PHP, it will only work to display results. In PHP you can uset he Joomla! code to get the values:
<?php
$weight = JRequest::getInt('weight', '', 'post');
$height = JRequest::getInt('height', '', 'post');
$bmi = $weight / ($height^2);
echo $bmi; 
?>
This assumes that the values are integers.

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