Creating a Simple online form

The most common use for online forms is a Contact Us form. The allows a website visitor to send you an email by typing in their details into a form without having a mail client installed. The instructions below are provided for users who have some programming knowledge. If you would like a quote to design, implement and test a form, please send an email to sales@passioncomputing.com.au with the fields that you require.

FormMail is a script that can allows you to program  your form to send email to a specified email address(es).  

Definitions: 'Script', refers to the FormMail.pl script, and 'mydomain.com.au', refers to your own domain name.

Please download the FormMail zip file (comprising both FormMail.pl (the script), and FormMailExample.html (a form)). The main goal of the steps below, is to ensure that nobody can abuse it for spam, or any other malicious purpose. We will make two modifications to FormMail.pl, to control who is allowed to use the script, and one modification to the form, to control where the email will go.

Step 1.
Open up FormMail.pl in NotePad as there are two things that need to be configured in the script. The file is laid out in a reasonably simple fashion: first, there is some copyright related information (nothing to see here, so scroll down), then some user-configurable information (this is where you'll be doing things), and then all the processing (nothing to do here).

Step 2.
Look for a line that looks like this: @referers =('mywebsite.com.au','myothersite.com.au'); This line will control what websites can use the FormMail script. If you have one website, smallbusiness.com.au, then you'll want to make the line look like this: @referers = ('smallbusiness.com.au '); You can add more domains (for example, if you have other websites, but want them to use the FormMail here), to that list by adding more domains to the list, as shown in the original example. More complex examples can be found in the readme at: http://www.scriptarchive.com/readme/formmail.html#setting_up

Step 3.
Look for a line that looks like this: @recipients = &fill_recipients(@referers); This line will control what email addresses FormMail can send email to. Remember that many forms can use a single script, so there is a need to ensure that your FormMail script will only allow the email addresses you want.

By default, it will allow you to send an email to any email address that belongs to the domains you set above for @referrers. So if you allowed the domain mysmallbusiness.com.au, then info@mysmallbusiness.com.au, john@mysmallbusiness.com.au etc, will allow be on the 'allow list'. If you want to specify specific email addresses, a simple example is: @recipients = ('^bill@mylittlecompany\.com', '^myname@mydomain\.com\.au'); The reason for the ^ and the \ symbols in what would otherwise be an ordinary email address, is to prevent people from trying to hack your forms and use it for spam etc.

More complex examples of how to specify a range of email addresses can be found in the readme at http://www.scriptarchive.com/readme/formmail.html#setting_up You can close FormMail.pl now.

Step 4.
Open up FormMailExample.html in Notepad (NOT Internet Explorer/Firefox) and find the line that looks like this: <input type="hidden" name="recipient" value="myname@mydomain.com" />. Replace 'myname@mydomain.com' with the email address you want the form to send the email to. That's it! You can close FormMailExample.html

Step 5.
Upload FormMail.pl to your /cgi-bin/ directory. This is not /httpdocs/cgi-bin/, but simply, /cgi-bin/.�� Login to the hosting control panel, and click "File Manager", then "cgi-bin/". Click on the permission link next to FormMail.pl (-rwxr--r�). Check the "Owner" tick box under "Execute/search mode", and then click "Ok".� Test that you have correctly uploaded the file by visiting http://www.mydomain.com.au/cgi-bin/FormMail.pl in your browser. You should see a generic message saying "FormMail ... Copyright 1995 - 2002 Matt Wright" etc.

Step 6.
Upload FormMailExample.html to your /httpdocs/ directory. Test that you have correctly uploaded the file by visiting http://www.mydomain.com.au/FormMailExample.html in your browser. You should see a basic form. If you fill out the form and press submit, you should receive an email with the contents of your form submission.