Problem with email template

tpoole614 28 Oct, 2013
I am trying to use custom code in my email template so that unused fields are stripped out. This is what I am using:
<p>
<?php
$var_array = array(
  'Childs Name' => 'Name',
  'Childs Age' => 'Age',
  'Address' => 'Address',
  'City' => 'City',
  'Zip' => 'Zip',
  'Boy' => 'Boy',
  'Girl' => 'Girl',
  'Life Events' => 'Events',
  'Special Present' => 'Present',
  'Parents Name' => 'Parent',
  'Parents Phone' => 'Phone',
  'Parents Email => 'Email'
);
foreach ( $var_array as $k => $v ) {
  $temp =& JRequest::getVar($v, '', 'post');
  if ( $temp ) {
    echo "<strong>{$k}</strong>: {$temp}<br />";
  }
}
?>
</p>


When the form is submitted, this is what I am receiving in the email:

Parse error: syntax error, unexpected T_STRING, expecting ')' in /home/content/19/7594019/html/administrator/components/com_chronoforms/form_actions/email/email.php(51) : eval()'d code on line 4

I know very little about PHP. Can you help me find the problem?
GreyHead 28 Oct, 2013
Hi tpoole614,

You are missing a ' on this line
  'Parents Email => 'Email'
.

And I'd suggest that you use the ChronoForms $form->data array instead of JRequest:
foreach ( $var_array as $k => $v ) {
  if ( isset($form->data[$v]) && $form->data[$v] ) {
    echo "<strong>{$k}</strong>: {$form->data[$v]}<br />";
  }
}

Bob
tpoole614 28 Oct, 2013
Thank you so much! I kept looking and just couldn't find it. It works perfect!
This topic is locked and no more replies can be posted.