Contact Form

Contact Form Configuration Options

Contact form is very customizable. You way want to:

Change the Look and Feel

As of ContactForm version 1.3, the look and feel is controlled via a simple template system. A template is simply an HTML file with four variables that get replaced with content by Contact Form.

The default template is very simple:
<html>
<head>
<title>$title</title>
$css
$javascript
</head>
<body>
<h1>$title</h1>
$content
</body>
</html>

Add Fields

Contact form comes with standard name, address, subject and message fields. It is very easy to add additional fields. There are several unused examples included in the contact form configuration. When you add additional field you need to add them to the @FormFields list.
	'phone', {
		# A regular expression describing a properly formatted field.
		# Uses on of the included pre-canned types as enumerated below
		'required' => $PHONE_OPTIONAL,
		# What to display to the user when the field is not filled in correctly
		'error' => 'The phone number you entered does not appear to be valid.',
		# Type of the field, this will display as a free form entry text box
		# Other types such as selects, text areas, and radio buttons are available
		'type' => 'text',
		# Text to display next to the field for the user
		'description' => 'Phone Number:',
	},
There are plenty of prebuilt regular expressions to choose from:

Restrict the Referrer

Changing this will prevent other sites from linking to your contact form. You would want to consider this especially if some other site sets up a button that allows users to click the button to immediately send you a prefilled email - effectively spamming you with the same message over and over.

Other email forms have hyped this as a security feature. However this method cannot prevent a specially designed program from automatically sending email through your server. Contact form hides email addresses makes the form much less of a target for such spammers because they cannot use it to send email to just anybody.

Allow International Characters

It would be possible to change the character set used in contact form from Latin 1 (ISO-8859-1) to Unicode (UTF-8) or something else that can handle characters in a wider variety of languages. To do so simply modify the my $charset variable.

Turn Off Client Side Verification

Setting use_client_side_verification to 0 will turn off the javascript check in the browser that makes sure the form elements are valid before submission. Contact Form also does a server side check, so this is not needed (in fact some browsers can't handle it and Contact Form doesn't make them do the check). You might want to turn this off if you don't want users to be able to look at the source of the page and figure out what patterns you actually would accept for certain fields.

Drop Down Select Lists

Contactform now has the ability to do drop down lists. To set up a selection field and its options, you need to do two things. First, in the Form_Type variable, set the field to "select". Second, in the Form_Fields variable set the regular expression for the field to be a pipe separated ('|') list of options. The "state" field is done for you as an example. The 50 states are given as options and the user can select their state from a pull down list. If your options have spaces in them, they should be enclosed in parenthesis like so: "(Option one)|(Option two)|(Option three)". Punctuation is not supported in options, stick to only letters, numbers, and spaces.

External XML File Configuration

Contact form can be difficult to upgrade if significant configuration changes are made directly in contact.pl. Contact form supports an external XML configuration file for all possible configuration options. An example configuration is included with the download.

Copyright (C) 2002-2020 Stephen Ostermiller

ostermiller.org (site index)