Accessing submitted form data from inside the emails

You have access to the form object in the email $form and therefore you can access submitted form data by using the code below. The string you pass in to getValue() should be the unique name of the element that you specified in the process.php file and the name attribute in the form HTML. The code below will display the submitted email address. You can use this code in both notification
email and the autoreply email.

1
<?php echo $form->getValue('email'); ?>
<?php echo $form->getValue('email'); ?>

Display submitted form data formatted in HTML

The above code will return the raw value of the form element, which can sometimes be an array (for multi-checkbox elements for example). If you use the method getValueHtml() instead, it will guarantee that the value will be displayed properly in the HTML email. This method takes two arguments, the first argument is the unique element name, the second argument (optional) is the string separator that will be used to join array types, this defaults to '<br />'. Use the code below to safely display a submitted value in the HTML email file.

1
<?php echo $form->getValueHtml('unique_element_name'); ?>
<?php echo $form->getValueHtml('unique_element_name'); ?>

Note: just replace unique_element_name with the name of the element you specified in process.php to get any submitted form value. The returned data is filtered according to any filters you added in process.php.

Still having trouble? Head over to the forums.

Forums