if statement inside email $MESSAGE_BODY
Posted: Thu Jun 16, 2011 8:42 pm
I'm using the standard (?) method to send email from a rather complicated form:
mail($to, $subject, $MESSAGE_BODY, $headers);
It's almost working exactly as I want - however, if certain form fields weren't used, I don't want to display them in the email.
So, here's what I've got on my normal page:
<?php if ($primary_tc_travdates == 'yes'): ?>
<strong>Depart Date:</strong> $tc_depdate - <strong>Return Date:</strong> $tc_retdate
<?php endif ?>
How do I translate this over into my $MESSAGE_BODY?
All other variables like the below are working as expected:
<p><strong>$prim_fname $prim_lname</strong> <br />
Phone: $prim_phone <br />
Email: $prim_email <br />
Date of Birth: $prim_dob</p>
mail($to, $subject, $MESSAGE_BODY, $headers);
It's almost working exactly as I want - however, if certain form fields weren't used, I don't want to display them in the email.
So, here's what I've got on my normal page:
<?php if ($primary_tc_travdates == 'yes'): ?>
<strong>Depart Date:</strong> $tc_depdate - <strong>Return Date:</strong> $tc_retdate
<?php endif ?>
How do I translate this over into my $MESSAGE_BODY?
All other variables like the below are working as expected:
<p><strong>$prim_fname $prim_lname</strong> <br />
Phone: $prim_phone <br />
Email: $prim_email <br />
Date of Birth: $prim_dob</p>