Forums

Using form variables in thank you message

peter49 30 Sep, 2016
Hi,

the answer will most certainly be around somewhere, but I couldn't find it sofar.
One of my form variables denotes a number and in the Thankyou message I would like to use this number and present the result to the user. In former days I wrote something like:

Please pay us
<?php
 $count = Jrequest::getVar(‘number’,‘’, ‘post’); 
 $total = $count * 12.5;
 echo ‘€ ’, number_format($total, 2);
?>
 for your order.


This no longer works in ChronoForms5/Joomla 3.6.2/PHP7.
How should I do this nowadays?

Regards,
Peter
peter49 30 Sep, 2016
Additionally to the above:
I tried
<?php
$count = $form -> data['number'];
$total = $count * 12.5;
echo ' € ', number_format($total, 2);
?>

according to documentation found, but here the ">" in "$form->data" is apparently interpreted as closure of the "<?php" fragment, although there is no question mark present.
A bug?

Regards
Peter
GreyHead 30 Sep, 2016
Hi peter49,

No I don't think so, maybe some typos. Please remove the spaces round - >
<?php
$count = $form->data['number'];
$total = $count * 12.5;
$total = number_format($total, 2);
echo ' € '.$total;
?>

Bob
peter49 02 Oct, 2016
Hi Bob,

thank you for answering, but too bad!
When the Thanks Message Content:is

Maakt u s.v.p. 
<?php
$aantal = $form->data['reserv_aantal'];
$totaal = $aantal * 12.5;
echo ' € '.$totaal;
?>
 (= {reserv_aantal} x €12,50) over 

then after enhtering 3 as 'reserv_aantal' quantity the actual thanks message is:

Maakt u s.v.p. data['reserv_aantal']; $totaal = $aantal * 12.5; echo ' € '.$totaal; ?> (= 3 x €12,50) over 

This happens both when using Internet Explorer and Firefox. Any more ideas?
By the way, I still use the simple setup mode.

Regards,
Peter
GreyHead 02 Oct, 2016
Hi peter49,

Sorry, I missed an important bit - you can't use PHP in a Thank you message action (I think that is because it has the WYSIWYG editor option). Please use the same code in a Custom Code action instead - that does support PHP.

Bob
peter49 03 Oct, 2016
Hi Bob,

that makes sense. I could tackle my problem with
- a hidden variable, defined in the designer
- it gets a (current date/time) value in custom code just before the email
- used as {...} in Display Message.

Problem solved, thank you
This topic is locked and no more replies can be posted.