Form Fields

For each form field the script will automatically create a placeholder with the same name as the form field. That comes in handy If an error occurs (i.e. the user forgot to fill in a required field) and the form appears again, the script can pre-populate the form fields so the user doesn't have to fill in all fields again. For example:

<input type="text" name="lastname" value="{lastname}">

The script will replace {lastname} with the value that the user entered before he submitted the form.

You can add as many fields to a form or change the fields of the example forms that come with the script. Please make sure that the field names and the placeholder names do not contain white spaces, or special characters. They may have underscores (first_name), though.

Select Menus

The script can process select menus like following:

<select name="" size="">
  <option value=""></option>
  <option value=""></option>
</select>

The script can also process multiple select fields. You can find an example in the HTML template /templates/example_multiples/form.tpl.html.

In order to make sure that the user's selection appears after submitting the form for preview, you can use a special placeholder.

<select name="Salutation" size="2">
  <option value="Mr" {select:Salutation=Mr}>Mr</option>
  <option value="Ms" {select:Salutation=Ms}>Ms</option>
</select>

The placeholder {select:Salutation=Ms} consists of the following elements. In the first position is the type of form field you are using. In this case it is a select menu (= select). After that follows a colon (:). In the second position is the name of the form field. In the example above that is Salutation. After that an equal sign (=) follows. At the last position comes the value of the option tag ([[value=""]]).

To make the selected value appear within the mail template, you need to enter the field name surrounded by curly brackets { } in the mail template, i.e. {Salutation}

In case a user did not select one of the options the script removes the placeholder from the mail template.

If you want a select field to be a required field and you have listed it in the required_fields form field, the first option of the list has to have an empty value. Otherwise the script will not show an error.

<select name="Salutation" size="2">
  <option value="">Please select</option>
  <option value="Mr" {select:Salutation=Mr}>Mr</option>
  <option value="Ms" {select:Salutation=Ms}>Ms</option>
</select>

You can find more examples in the template /examples/advanced_form.tpl.html.

Checkboxes

The script can process checkbox fields like following:

<input type="checkbox" name="" value="" />

The script can also process multiple checkbox fields. You can find an example in the HTML template /templates/example_multiples/form.tpl.html.

In order to make sure that the user's selection appears after submitting the form for preview, you can use a special placeholder.

<input type="checkbox" name="Newsletter" value="Yes" {checkbox:Newsletter=Yes} />

The placeholder {checkbox:Newsletter=Yes} consists of following elements. In the first position is the type of form field you are using. In this case it is a checkbox field (= checkbox). After that a colon (:) follows. In the second position is the name of the form field. In the example above that is Newsletter After that follows an equal sign (=). In the last position is the value of the option tag (value="").

In order for the selected value to appear in the mail template, you need to enter the name surrounded by curly brackets { } in the mail template, i.e. {checkbox:Newsletter}.

You can find more examples in the template /examples/advanced_form.tpl.html.

Radio Buttons

The script can process [[radio button]] fields like following:

<input type="radio" name=" " value="" />

In order to make sure that the user's selection appears after submitting the form for preview, you can use a special placeholder.

<input type="radio" name="Salutation" value="Mr" {radiobutton:Salutation=Ms} />

The placeholder {radiobutton:Salutation=Ms} consists of the following elements. In the first position is the type of form field you are using. In this case it is a radio button field (= radiobutton). After that follows a colon (:). In the second position is the name of the form field. In the example above that is Salutation. After that follows an equal sign (=). In the last position is the value of the option tag (value="").

In order to make the selected value appear in the mail template, you need to enter the name surrounded by curly brackets - { } - in the mail template, i.e. {Salutation}.

You can find more examples in the template /examples/advanced_form.tpl.html.

Multiple Recipients

The script allows you to send a recommendation e-mail to an arbitrary number of recipients. The simplest way would be to add the desired number of form fields - one for each recipient e-mail - to your form.

You can select any field name (only alphanumeric and underscore), but every field name must start with the word "multiple_" (note the underscore) and end with a consecutively number "_1" (note the underscore).

In the folder "templates/examples/" you can find an example form and mail template. The HTML template file "multiple_recipientes_form.tpl.html" has been prepared for sending the recommendation e-mail to multiple recipients. The folder also contains the e-mail template file "multiple_recipients_mail.tpl.txt".

Let us suppose you want to let your visitors send e-mails to up to four recipients. If we choose, for example, the name "recipient_email" as field name, our multiple field names would be following:

multiple_recipient_email_1 multiple_recipient_email_2 multiple_recipient_email_3 multiple_recipient_email_4

The complete form fields would look like this:

<input type="text" name="multiple_recipient_email_1" value="{multiple_recipient_email_1}" />
<input type="text" name="multiple_recipient_email_2" value="{multiple_recipient_email_2}" />
<input type="text" name="multiple_recipient_email_3" value="{multiple_recipient_email_3}" />
<input type="text" name="multiple_recipient_email_4" value="{multiple_recipient_email_4}" />

The field names - surrounded by curly brackets - are automatically the template variables for the field values (value="...").

The script allows you to assign an arbitrary number of additional form fields to every recipient. Every field that starts with "multiple_" will automatically assigned to the corresponding recipient, based on the trailing number.

<input type="text" name="multiple_first_name_4" value="{multiple_ first_name_4}" />
<input type="text" name="multiple_last_name_4" value="{multiple_last_name_4}" />
<input type="text" name="multiple_recipient_email_4" value="{multiple_ recipient _email_4}" />

The script uses the same e-mail template file for every recipient. The template variables (those in curly brackets) have the same name as their corresponding fields in the form template. But you need to replace the trailing numbers with a question mark. The script recognizes those variables and replaces them with correct values. For example:

To: "{multiple_first_name_?} {multiple_last_name_?}" <{multiple_email_?}>

The script uses the same mail template file for all recipients. All non-multiple field values appear in every e-mail.

Required Form Fields

Every form field can be marked as a required field. This means that the e-mail will not be sent until these fields are filled in. Enter a comma separated list of field names that you want to be required into a hidden form field with the name required_fields. For example:

<input type="hidden" name="required_fields" value="lastname, email, subject" />

This will make the form fields lastname, email and subject required fields.

E-mail Syntax

Like the required fields you can define fields that you want to be checked for correct e-mail syntax. Enter a comma separated list of field names that you want to be checked in a hidden form with the name email_fields. For example:

<input type="hidden" name="email_fields" value="email_1, email_2" />

Advanced Error Messages

If a required field has not been filled in by the user, an error message will be displayed above the form fields. This is the default setting.

The script allows you to display error messages right beside, above or below a form field. Moreover, the script allows you to alter the appearance of the form field label.

In order to implement advanced error messages, following three placeholders are available:

{required:fieldname='Error message':endrequired}

{syntax:fieldname='Error message':endsyntax}

{error:fieldname='Default text'||='Error message':enderror}

{required:fieldname='Error message':endrequired}

Let us suppose you have a field last_name and you define it as required field. You can use following variable for the error message:

{required:last_name='Please enter your last name.':endrequired}

In case the visitor has not filled in the field, the variable will be replaced with the error message:

Please enter your last name.

You could format the error text using CSS:

{required:last_name='<span style="font-weight:bold;color:#FF0000;">Please enter your last name.</span>':endrequired}

The error text now appears in bold font and in red color:

{syntax:fieldname='Error message':endsyntax}

Let us suppose you have a field email and you define it as e-mail syntax field. You can use following variable for the error message:

{syntax:email='Please enter a valid e-mail address.':endsyntax}

In case the visitor has not filled in the field correctly, the variable will be replaced with the error message:

Please enter a valid e-mail address.

You could format the error text using CSS:

{syntax:email='<span style="font-weight:bold;color:#FF0000;">Please enter a valid e-mail address.</span>':endsyntax}

The error text now appears in bold font and in red color.

{error:fieldname='Default text'||='Error message':enderror}

You can use following variable if you want to change the appearance of the form field label. Let us suppose you have a field subject and you define it as required field.

You can use following variable in order to change the appearance of the label:

{error:subject='Subject'||='<span style="color:#FF0000;">Subject</span>.':enderror}

Without an error the first part (everything before the two vertical lines - pipes) will be displayed. In case the visitor has not filled in the field, the variable will be replaced with the second part:

For a better understanding you could take a look at the example in the folder /templates/examples_error_messages/.

Redirect Back or Thank You Page

After the form has been submitted the user will be redirected to the page he came from or you can define a special page in the following field:

<input type="hidden" name="redirect" value="{redirect}" />

In case you want to redirect the user to a certain page just replace the placeholder {redirect} with the URL of the thanks page.

Example:

<input type="hidden" name="redirect" value="http://www.example.com/thanks.html" />

Please enter the whole URL including http:// and the domain name (i.e.: http://www.example.com/).

In case you do not want to redirect back to the referring page or redirect to a thanks page you can display a confirmation page. That page can also contain the form values. Just edit following field:

<input type="hidden" name="redirect" value="{redirect}" />

And change it to:

<input type="hidden" name="static" value="{redirect}" />

The field name changes from "redirect" to "static".

Define HTML Template

If you are calling the script from an existing form in a HTML page and you do not want to use the default HTML file, you can define a different HTML file in a hidden form field with the name html_template. For example:

<input type="hidden" name="html_template" value="form.tpl.html" />

Define Mail Template

The mail template can be defined the same way. You have the option to define a single mail template. For example:

<input type="hidden" name="mail_template" value="mail.tpl.txt" />

You can also define more than one mail template. Each of these templates can contain different recipients and content. For example:

<input type="hidden" name="mail_template" value="mail.tpl.txt, mail2.tpl.txt" />