We are attempting to use php to pre-process a form email template's html before sending to both the admin and the user. The script is designed to strip empty fields before sending. We've looked at and tried to implement solutions from the other similar posts in this forum but can't seem to get it working. The form submits successfully to the database, there are no php errors displayed in the browser, and both emails send successfully (one to the applicant and one to the site admin), but there are blank form fields in the email still. I've posted the code below to show what we are pasting into the "On Submit Code - before sending email" field. Also, I can't seem to find where the php error logs are stored in the chronoforms component.
<?php
$parent_first_name = $form->data['parent_first_name'];
$parent_last_name = $form->data['parent_last_name'];
$house_number = $form->data['house_number'];
$street_name = $form->data['street_name'];
$street_type = $form->data['street_type'];
$city = $form->data['city'];
$province = $form->data['province'];
$postal_code = $form->data['postal_code'];
$home_phone = $form->data['home_phone'];
$work_phone = $form->data['work_phone'];
$cell_phone = $form->data['cell_phone'];
$primary_email = $form->data['primary_email'];
$secondary_email = $form->data['secondary_email'];
$student_one_name = $form->data['student_one_name'];
$student_one_birth = $form->data['student_one_birth'];
$student_one_gender = $form->data['student_one_gender'];
$student_one_room = $form->data['student_one_room'];
$student_one_start_date = $form->data['student_one_start_date'];
$student_one_tour_date = $form->data['student_one_tour_date'];
$student_one_programs = $form->data['student_one_programs'];
$student_two_name = $form->data['student_two_name'];
$student_two_birth = $form->data['student_two_birth'];
$student_two_gender = $form->data['student_two_gender'];
$student_two_room = $form->data['student_two_room'];
$student_two_start_date = $form->data['student_two_start_date'];
$student_two_tour_date = $form->data['student_two_tour_date'];
$student_two_programs = $form->data['student_two_programs'];
$current_student = $form->data['current_student'];
if ( $primary_email != "" ) {
?>
<p>This email is to notify you that your enrolment request has been submitted electronically via the website. Please keep this email for your records.
</p>
<?php
} else {
?>
<p>This email is to notify you that an enrolment form has been submitted electronically via the website.
</p>
<?php
}
if ( $current_student != "" ) {
?>
<p>Current Student (<?=$current_student?></p>
<?php
} else {
?>
<p>
<?php
if ( $parent_first_name != "" ) {
?>
<strong>Parent First Name: </strong><?=$parent_first_name;?><br />
<?php
}
if ( $parent_last_name != "" ) {
?>
<strong>Parent Last Name: </strong><?=$parent_last_name;?><br />
<?php
}
if ( $street_name != "" ) {
?>
<strong>Address: </strong><?=($house_number != "")?$house_number:""?> <?=($street_name != "")?$street_name:""?> <?=($street_type != "")?$street_type:""?><br />
<?=($city != "")?$city:""?><?=($province != "")?", ".$province:""?> <?=($postal_code != "")?$postal_code:""?><br />
<?php
}
if ( $home_phone != "" ) {
?>
<strong>Home Phone: </strong><?=$home_phone?> <br />
<?php
}
if ( $work_phone != "" ) {
?>
<strong>Work Phone: </strong><?=$work_phone?> <br />
<?php
}
if ( $cell_phone != "" ) {
?>
<strong>Cell Phone: </strong><?=$cell_phone?><br />
<?php
}
if ( $primary_email != "" ) {
?>
<strong>Primary Email: </strong><?=$primary_email?><br />
<?php
}
if ( $secondary_email != "" ) {
?>
<strong>Secondary Email: </strong><?=$secondary_email?>
<?php
}
?>
</p>
<?php
}
if ( $student_one_name != "" ) {
?>
<p>
<strong>Student #1</strong><br />
<strong>Student #1 Name: </strong><?=$student_one_name?><br />
<?php
if ( $student_one_birth != "" ) {
?>
<strong>Birth Date: </strong><?=$student_one_birth?><br />
<?php
}
if ( $student_one_gender != "" ) {
?>
<strong>Gender: </strong><?=$student_one_gender?><br />
<?php
}
if ( $student_one_room != "" ) {
?>
<strong>Room: </strong><?=$student_one_room?><br />
<?php
}
if ( $student_one_start_date != "" ) {
?>
<strong>Start Date Preferred: </strong><?=$student_one_start_date?><br />
<?php
}
if ( $student_one_tour_date != "" ) {
?>
<strong>Tour Date Preferred: </strong><?=$student_one_tour_date?><br />
<?php
}
if ( $student_one_programs != "" ) {
?>
<strong>Selected Program(s): </strong><?=$student_one_programs?>
<?php
}
?>
</p>
<?php
}
if ( $student_two_name != "" ) {
?>
<p>
<strong>Student #2</strong><br />
<strong>Student #2 Name: </strong><?=$student_two_name?><br />
<?php
if ( $student_two_birth != "" ) {
?>
<strong>Birth Date: </strong><?=$student_two_birth?><br />
<?php
}
if ( $student_two_gender != "" ) {
?>
<strong>Gender: </strong><?=$student_two_gender?><br />
<?php
}
if ( $student_two_room != "" ) {
?>
<strong>Room: </strong><?=$student_two_room?><br />
<?php
}
if ( $student_two_start_date != "" ) {
?>
<strong>Start Date Preferred: </strong><?=$student_two_start_date?><br />
<?php
}
if ( $student_two_tour_date != "" ) {
?>
<strong>Tour Date Preferred: </strong><?=$student_two_tour_date?><br />
<?php
}
if ( $student_two_programs != "" ) {
?>
<strong>Selected Program(s): </strong><?=$student_two_programs?>
<?php
}
?>
</p>
<?php
}
?>
Thanks