Forums

No PHP in Thanks Message?

HerKle 14 Nov, 2015
Hi,
I wanted to summarize the data sent by the form user in the Thanks Message action in OnSubmit and coded it with php. Unfortunately that gave a mess, showing parts of my code in the frontend. To check if my code was incorrect, I choose a simple example, but it still comes messy:
[attachment=0]thanks-message-php-frontpage.png[/attachment]

This is the code:
<?php 
echo "<h3>Thank you!</h3>";
?>


I didn't find any topic here describing my experience, so I wonder where I made an obvious mistake.

Regards,
Herbert
GreyHead 14 Nov, 2015
Answer
1 Likes
Hi Herbert,

You don't need PHP for that just
<h3>Thank you!</h3>
will work fine. And, if you want to include data from the form you can use the {input_name} syntax e.g.
<h4>Hi {first_name}, thank you!</h3>


For some reason that escapes me PHP is not supported here - if you need it you can replace the Thanks Message action with a Custom Code action. That behaves in exactly the same way in displaying the output and it accepts PHP.
<?php
$greet = 'Sir';
if ( $form->data['gender'] == 'f' ) {
  $greet = 'Madam';
}
?>
<p>Dear <?php echo $greet; ?>, . . .

Bob
HerKle 15 Nov, 2015
Thanks Bob,

I exactly did the same. (Btw I knew that I don't need php to just say "hello" – I did that for simplifying my test and caring for your well-being not to read tons of unnessessary code – ;-) )

Leaves only the task for Max and Co. to delete "PHP" in the subtitle of the code field and to mention that this one only accepts html, just to prevent others from my confusion…

Thanks again!

Regards,
Herbert
This topic is locked and no more replies can be posted.