![]() | Welcome to Islandnet.com Locally owned and operated since 1993 |
| Create an Account • Pricing & Features • Domain Registration • Customer Sites • Help & Info | |
Saturday February 11 2012 | |
MailitSynopsisThis gadget is like a swiss-army form processor. It can take the results of a form submission and display it to the user, email the results to you, and even write the results into a file. It has support for mandatory fields (users cannot submit the form if certain fields are left blank), and support for field format patterns (users cannot submit the form if certain fields do not match a specified format). It can even automatically email pre-written messages to users who check off certain items on your form. For those that need more immediate notification, this gadget can send a message to your pager or fax machine too.
SetupHere is the minimal setup required at the top of a form:
<form method="post" action="/cgi-bin/mailit"> <input type="hidden" name="login" value="guest"> <input type="hidden" name="reply" value="REPLY">The first line marks the beginning of your form, and specifies mailit as the gadget to process the form. On the next line, replace LOGIN field's VALUE with your true islandnet login. You cannot use an email alias here. The REPLY value should specify either a full URL or a filename relative to your "www" directory. If it specifies an URL, then the user's browser will be redirected to that URL once the form data has been processed. If it is a file name, then that file will be displayed using the same rules that apply to a template file. NOTE: When specifying a file, a ".rep" extension will be assumed. This means that to display the "thanks.rep" file you would specify "thanks" without an extension. Of course you need to close off the form with some lines like: <input type="submit" value="Submit"> </form>That is all that is required to make it work. You can add any number of additional fields to your form - all of them will appear in the email message you receive. However, there are additional options you can set if you want to make it a bit more sophisticated.
Controlling Email ParametersBy default, the form results will be emailed to the LOGIN name specified above, and the form will appear to have come from "nobody@islandnet.com". If the form results should go to another islandnet address, simply add a line like this:
<input type="hidden" name="to" value="LOGIN">and replace LOGIN with another islandnet login or email alias. You cannot specify a non-islandnet address, and any '@' symbols will be stripped out and "@islandnet.com" appended. You can also specify a TO value of "nobody", which will prevent any mail message from being sent (useful if you are only writing the data to a file). If you want to be able to reply to a form submission, you will need to obtain the user's email address. It is not possible to do this automatically, so it will have to be a form input field. If (and ONLY if) you call this field "EMAIL", then the message you receive will appear to have come from the user instead of "nobody". Use a line like this:
Enter your email address: <input name="email"> Rejecting Submissions From Certain SitesUnfortunately, it is sometimes necessary to disallow form submissions from specific sites, usually due to abusive or prank messages. By optionally making use of an Accept File, you can accept or reject submissions based on the user's IP address and/or host name. Just add two additional hidden values like this:
<input type="hidden" name="acceptfile" value="ACCEPTFILE"> <input type="hidden" name="rejectmsg" value="REJECTMSG">Replace "ACCEPTFILE" with the name of an ASCII text Accept File. This file is relative to your root directory, allowing it to reside outside of the area accessible by a browser. Replace "REJECTMSG" with the name of an HTML file that should be displayed if the user's site is rejected. This one is relative to your "www" directory.
Controlling the Output FormatBy default the mail message you receive is simply a list of all the form variables, followed by their values, one per line. The date and time, as well as the IP number of the user's computer are included for security. However, sometimes it is nicer to have the results formatted differently. This gadget can pass the data through a template file before mailing it to you, which allows you to format the results your own way. Assuming you have created a template file called "order.tpl", you can use it like this:
<input type="hidden" name="template" value="order.tpl">The filename is relative to your "www" directory and can be named anything you want.
Mandatory FieldsYou can make certain fields mandatory by adding an option like this:
<input type="hidden" name="mandator"y value="email name">Simply list the name of each mandatory field in the value, separated with spaces. In the example above, the user is required to fill in both the EMAIL and the NAME fields. If not, an error will be displayed listing each field that is missing required data. They will not be able to submit a form to you until they have filled in each required field. Sometimes you may want certain fields to be mandatory (or not) based on the content of another field. Your form may, for example, have a section that is only mandatory if a certain checkbox has been turned on. Or one field may be mandatory only if the value in another is greater than a certain amount. You can do this in the following manner:
<input type="hidden" name="mandatory" value="age name?age>18">In this example, the AGE field is always mandatory, but the NAME is only mandatory if the AGE is greater than 18. To have a conditional mandatory field, you simply add a question mark, then the name of the variable that it depends on, then an operator, then a value to test against. You cannot include any spaces. The available operators include:
Input Field FormattingNow suppose you need to ensure that the user fills in a field following a specific format. In other words, you want to reject the submission if certain field entries do not match a given pattern. To do this you simply need to provide a format specifier for each field that needs one.
<input name="telephone">The above example is a simple input field. As it is, the user could actually type in anything they want. But add another field like this:
<input type="hidden" name="fmt-telephone" value="(999) 999-9999">and the field will be rejected if what they entered did not match the pattern. Note that you want to make format specifiers HIDDEN, and their name must start with "fmt-", followed by the name of the field it applies to. The pattern itself must match the input data character for character. The following codes match certain ranges of letters and numbers. All other characters in the pattern must be matched literally.
The gadget also has special support for validating credit card numbers. This is extremely useful for eliminating prank submissions and typos. For example, if you want to ensure that a credit card number entered is a proper VISA or MasterCard number, you could specify a format pattern like this:
<input type="hidden" name="fmt-ccnum" value="%vm">The key here is that the format pattern begins with a % symbol, which indicates that the field should match one of the following credit card numbers. The letter 'v' indicates that any valid VISA numbers should be accepted, and the 'm' means it should also accept valid MasterCard numbers. The supported credit card numbers and their codes are as follows:
You must include a code letter for each credit card type you wish to accept. The number entered will be checked for the proper number of digits, the proper prefixes, and a special algorithm will be applied to ensure that the digits consitute a valid credit card number (as opposed to a random string of digits). It does not matter if the user includes spaces or dashes, only the digits themselves count. As well, there are some special format specifiers you can use. A format with the value "email" means that the user must enter an email address. An email address is considered valid if it has a string of characters followed by one (and only one) @ symbol, followed by at least two more sets of characters with a period separating them.
Customizing the Error ScreensThe default error page that is displayed is rather dull. If you want the error message to have a similar look and feel to your other pages, you must also include the following two options:
<input type="hidden" name="errorhdr" value="HEADERFILE"> <input type="hidden" name="errorftr" value="FOOTERFILE">Replace HEADERFILE with the name of a file that will be inserted ABOVE the error messages, and FOOTERFILE with the name of a file that will be inserted BELOW the error messages. The filenamed must end with a .html extension, but you only need to reference the first part in the fields above. These are relative to your "www" directory. A sample might look like: <input type="hidden" name="errorhdr" value="header"> <input type="hidden" name="errorftr" value="footer">If you had the files header.html and footer.html in your main "www" directory.
Emailing Automated ResponsesThis gadget can even help lessen your work load by automatically emailing canned messages to the user, based on checkboxes that the user turns on and off. These are known as auto responders. For example, you might have three check boxes on your form that allow the user to request more information on three different fast food chains. For each item they check, they will receive an email message, from you, containing the info requested:
McDonalds: <input type="checkbox" name="ar-mcdonalds"> Wendys: <input type="checkbox" name="ar-wendys"> KFC: <input type="checkbox" name="ar-kfc">Note that the field names all start with "ar-". That is the key. The part after the dash is the actual name of the file (relative to your "www" directory with a ".txt" appended to it) that should be emailed to the user. In the example above, if the user has checked the KFC option, they will be emailed the file "kfc.txt". The autoresponders were designed to work with checkboxes as above which have a value of "on" when selected. If you don't want the user to have to make a selection, you can emulate a checkbox by using a hidden field, something like:
<input type="hidden" name="ar-kfc" value="on">NOTE: The file is first processed as a template file before being emailed, so you can include form values in the message on the fly. If you do NOT want the responder file treated as a template file, add a single exclamation point to the field name. In the above example, "ar-kfc" would send the file "kfc.txt" after it has been processed as a template file. "ar-kfc!" would just send the raw file without processing. This is useful if your file contains text that might otherwise be replaced by the template processor. Note that auto responders will only work if you have asked the user for an EMAIL address. If the field EMAIL does not exist or is empty, no files will be sent. The default subject for auto responders is simply "Auto Responder: FILE", where FILE is replaced by the filename requested. You can override this and specify your own subject by adding an additional line like this:
<input type="hidden" name="ar-kfc" value="on"> <input type="hidden" name="ars-kfc" value="More info on KFC!">Note the field name starts with "ars-" and is followed by the name of the file. By default the From: header as seen by the recipient of an auto responder will indicate your islandnet address (ie: somebody@islandnet.com). Those with their own domain name may wish to override this value. Do it like this:
<input type="hidden" name="sender" value="somebody@somedomain.com"> Writing Data to a FileBy adding three additional lines, you can have the gadget write the form data to a file in your account. It can write all of it, or only selected fields. It can write it in tab delimited format, comma delimited format, comma delimited with quoted fields, and "human readable" format. You can also use a template file to customize the format.
<input type="hidden" name="file" value="FILENAME"> <input type="hidden" name="format" value="FORMAT"> <input type="hidden" name="fields" value="FIELDS">Replace FILENAME with the name of the file in your account to which the data should be written. If the file already exists, the data will be appended to it. If the file does not exist, it will be created for you. Note that the filename is relative to your root directory, not your web directory. This means that you can create data files that are NOT in your web directory, therefore they cannot be read directly by a browser. If you want the data file to appear inside your web directory, add "www/" to the front of the file name. Regardless of the filename you specify here the gadget will append a ".db" extension. The next line specifies the format that should be used when writing the data. If you set FORMAT to "tab", then each field will be separated with a single tab character. If you set it to "comma", then a single comma will separate each field. Using "quote" is the same as "comma", except that each field will also be surrounded in a pair of quotes. Setting this value to "human" will write each field on a separate line of the file like this: Fieldname: fieldvalue. Any other value will be taken to be the filename of a template file, relative to your "www" directory. In the next line, replace FIELDS with a space-separated list of field names in the order that they should be written to the file. If a field name does not appear in this list, then it will not be written. This value is required only if you use "tab", "comma", "quote", or "human" formats. If you are going to use a template file then this value is ignored. The FILENAME setting may contain special codes that will be replaced with values on-the-fly by the gadget. For example, if you specified a filename like this: abc{$REMOTE_HOST} then the actual filename used would be "abc", followed by the user's hostname or IP address, followed by ".db". This allows you to record data to different files based on the content of a form variable. You can specify up to three different files to be written to, each with a different format, template file, etc. To write data to a second file, just add three more lines similar to those above:
<input type="hidden" name="file2" value="FILENAME"> <input type="hidden" name="format2" value="FORMAT"> <input type="hidden" name="fields2" value="FIELDS">Note the "2" on the end of each field name. You can write to a third file by adding another three lines that use FILE3, FORMAT3, and FIELDS3. You cannot write to more than three files.
Notification Via Your PagerWith one extra line of HTML and a tiny one-line config file, this gadget can send a message to your RadioWorks, CanTel, or BC Tel Mobility pager. This works for both numeric pagers and pagers that can display text.The first thing you need to do is add this line to your form:
<input type="hidden" name="pagermsg" value="MESSAGE">Simply replace MESSAGE with whatever you want to appear on your pager. If your pager is numeric only, then your message must consist only of numbers, spaces and dashes. If your pager can display text, then anything can be used as a message. Instead of making this a hidden value you could allow a user to type in the message, or you could make them select one from a pull down list. An empty or missing value will not be sent to your pager. This is all you need to do from an HTML point of view. Now all that's required is to specify your pager number and paging service provider. Rather than embedding your pager number in the form itself, the gadget will look for a special file in your root directory called "pager.id". The "pager.id" file is a plain text file that contains a single line of the following format:
SERVICE-numberWhere "SERVICE" should be one of "RADIOWORKS", "CANTEL", "CANTELPCS", "BCTEL", "PAGENET", "MICROCELL", or "DIALDIRECT", depending on who you get your paging service from. "number" is the PIN number of your pager (usually a telephone number). For example, if you use RADIOWORKS and your pager ID is 555-1234, your pager.id file would look like this:
RADIOWORKS-5551234Telus Mobility pagers require one extra digit at the beginning of the pager number. Insert a '0' if your pager is from the 604 area code, and a '2' if it's from the 250 area code.
TELUS-05551234Cantel PCS, Microcell, and Clearnet "Mike" customers must include the area code as well as the 7 digit phone number, making 10 digits in total.
CANTELPCS-2505551234islandnet is in no way responsible for lost or missing pager messages. Messages may be periodically lost due to problems at your paging service's dispatch center, or simply due to the nature of radio transmissions.
Faxing Form ResultsIf you are accepting orders over the internet, it's not always convenient to check your email every couple of hours to ensure timely processing. You may find that having a copy of a submitted form sent to your fax machine enables you to respond more quickly to customer orders and inquiries.A faxed copy of a form submission will look exactly the same as the emailed version. If you use a template to format the results, then it applies to the faxed copy as well. Using the fax option does NOT stop the emailed copy from being sent. To forward form results to a fax machine, add this single line to your form:
<input type="hidden" name="fax" value="Victoria">That's all you have to do as far as your HTML is concerned. Next you have to specify the fax number to send the results to. Rather than embed a fax number in the form itself it is stored in a separate file called "fax.id" in your root directory. This is a simple text file containing a single line of text: your fax number. The fax number must be exactly seven digits long or the fax will not be sent. It must not contain any characters other than numbers (no dashes, spaces, etc.). You can have one fax number per account. islandnet is in no way responsible for faxes that don't get through. Faxes will be attempted multiple times and then deleted. It is up to you to ensure that your fax number is not busy, that your fax machine is not out of paper, etc.
|
| Home • About Us • Contact Us • Terms of Use • Privacy Policy • Help Documents |
| Page generation time: 0.01 seconds |