Writing Forms For Use With ASForm


Introduction

Fortunately, because of the bother you've have to go through to create a configuration file (or maybe several) for ASForm, here's where the payoff comes. For the most part, you don't really have to do anything special with your forms unless you're using optional features of ASForm, and even then it's easy. As you've probably read by now, ASForm doesn't want all of it's configuration in the HTML.

If you don't know all that you need to know about creating HTML forms, this document won't teach you. You might want to look into what the World Wide Web Consortium (AKA "The W3C") has to say about it, in the driest way possible, at http://www.w3.org/TR/REC-40/interact/forms.html#edef-FORM. You might want to look at what my Usenet acquaintance Joe Barta has to say about it in his Form Tutor at http://junior.apk.net/~jbarta/tutor/forms/lesson01.html, keeping in mind that although he mentions "mailto" forms, he also tells you why they generally suck in a nicer way than I ever could ;-)

The Basics

You should know where you've installed ASForm, or will install ASForm, so be sure that it's indicated in your action. The method is up to you unless you're using a secure HTTPS server, in which case ASForm forces you to use the method POST. So we'll use POST in this example:

<form action="cgi-bin/asform.cgi" method="POST">

{ ... all your form stuff ...}

</form>

Whoa -- where's all that stuff like the other form processors require? Well, if you're using ASForm with only one possible recipient or multimail mode, the Autoresponder is not in user mode, and you are using the default configuration file, you don't need all that stuff. Payoff.

Note: When naming your inputs, any name that begins with email or hide_email automagically becomes required, and has to pass muster as a properly formatted email address. If you don't want this to happen, don't name the input that way.

Using named configurations

If you have more than one configuration and you don't want this form to be processed by the default configuration, you have to tell ASForm which one to use. If you have a line in your configuration file like this:

altconfig: (another) asform2.cfg, (yet_another) asform3.cfg

and the configuration you want to process this form is asform2.cfg:

<input type="hidden" name="config" value="another">

will do the trick quite nicely. If you want to allow the user's input to determine which configuration file to use, you can use any input element you want to use that's mutually exclusive. With radio buttons, for example:

<input type="radio" name="config" value="another"> This way <br>
<input type="radio" name="config" value="yet_another" checked> That way

You probably want to use checked to set a default value in a case like this one -- if config comes along without a value, ASForm will return an error message to the user and mail a Fatal Error report to the webmaster. Not good.

Specifying recipients (not in multimail mode)

This is done just like named configurations, but instead you use an input named recip and an alias from your configuration file's recipients. For example:

<input type="hidden" name="recip" value="bob">

Or any form element you want to use that makes sense. Text boxes might work for you, but are probably not the best idea. Live like you want to live.

Autoresponder in user mode

You guessed it, it's just like the others. Use any old input element you want, with the name autorespond and the value being on or off.

Hiding data from echo

In general, all you have to do to hide form data from echo is to prepend its name with hide_ so it looks something like hide_secretstuff. It will still be available to dump, of course.

The rub is that moving an HTTP environment variable into sort order exposes it to echo. You might think this is exactly what you want to do, or you might think it's exactly what you don't want to do. Maybe you don't want your users knowing that you're snooping on which browser they're using, but you want to be able to sort that information. The workaround for this is to use Server Side Includes, and if you can't do that, well, there's no workaround. Here's the example:

<input type="hidden" name="hide_ua" value="<!--#echo var="HTTP_USER_AGENT" -->">

If you're not up on using SSI, you might give a look at the artsackett.com grey paper SSI For The Rest of Us.

So, with this workaround in place, you add hide_ua to your sort order and it is not exposed to echo because it is hidden, and you've still collected that data you wanted without the user knowing it unless the user views the source of your HTML. It's not a perfect world...


Index
[online]
Introduction/
Features
Configuration Installation
 
Customizing
Error Messages
Writing
Message Templates
Writing Forms for
Use With ASForm
Running
ASForm Debug

 

© 1999 - Art Sackett