condition if then in emails

How to use conditional if-then logic in ChronoForms emails.

Overview

The issue occurs when using incorrect syntax for form data variables and comparison operators in PHP code within the email template.
Replace the placeholder syntax with the correct form data array variable and ensure you use the double equals comparison operator in the if statement.

Answered
ChronoForms v5
Er ErixSr 06 Dec, 2017
Hello everyone,
I can not figure out how to do the if-then condition in the email.
I tried:


<td colspan="2" align="center"><b>L'indirizzo di spedizione è lo stesso?:</b> <b><font size="3" color="red">{spedizione}</font></td></tr>

<?php
$Risp = "{spedizione}";

if ($Risp = "Si") { 
  echo 'La risposta è SI';
} else { 
  echo 'La risposta è No';
}
?>

</table><br>



Where {spedizione} is a radiobutton, the answer is: Si / No

If I select Yes or select No, the answer is always there "La risposta è SI"

Where am I wrong?
Gr GreyHead 06 Dec, 2017
Answer
Hi ErixSr,

You can't use the {input_name} syntax in PHP please use $form->data['input_name'] instead. You also need == in the if statement, not just = e,g,
<?php
if ( $form->data['spedizione'] == "Si" ) { 
echo 'La risposta è SI';
} else { 
echo 'La risposta è No';
}
?>

Bob
Er ErixSr 06 Dec, 2017
Tiredness and especially lack of preparation make stupid questions like mine ...
Thank you Bob,
This topic is locked and no more replies can be posted.