Implementation testing:
1. Put web_form.htm in sub-dir test
2. put FormMail.pl in http://weberland.tripod.com/cgi-bin/pl-lib/FormMail.pl
3. redirection is set to http://weberland.tripod.com/
There are two things that need to be in every form you use with the form handler, plus two more optional items, all of which you can see in the example above: The form's ACTION needs to point to either "/bin/script_library/form_handler_file" or "/bin/script_library/form_handler_mail". The first will save the form data in a file, named in the same way as the form, but with a .txt on the end (so if your form page is named 'mypage.html', the data will be saved in 'mypage.html.txt'). The second will email you the data instead, sending it to the address you gave Tripod when you signed up. You need a hidden input, named "end_display", which has as its value the name of the page that we should go to after the form gets submitted.
You can use a hidden input named "required" to list any inputs that you want to make sure that the user fills out. If a required field doesn't get filled in, the user will get an error telling him or her to try again.
Lastly, you can use a hidden input named "order" to specify the order in which you want data from the form to be displayed. Otherwise, it will be displayed in a random order. Other than these requirements, you can put whatever inputs you want into the form - they'll all get saved, either as a file or sent to you as email, depending on which ACTION you chose for your form.
Tripod Mail Program
CGI
is frequently used for e-mailing purposes, whether it be a site manager sending
e-mail to visitors or information compiled from a site's forms being mailed to
the site's owner. In order to do either task, a script needs access to an e-mail
program. Tripod has provided its users with a module called TripodMail.pm. To
get that module, you'll need to load it into your cgi-bin here. However, Tripod's mail
module doesn't function exactly like the mail programs you may have used
before.
You need to have a mail template in your directory which contains
the normal fields, such as "To," "From," and "Subject." You can include
variables in that template. There is a method of the TripodMail.pm module called
"sendMail". This method needs two bits of information: the name of the mail
template in your directory, and a hash of variables. These are the same
variables that are referred to in your template. Say you had a template that
looked a bit like this:
To: $recipient
From: $sender
Subject:
$subject
$body
$signature
You could then use the
TripodMail module to send e-mail by creating a new instance:
require
TripodMail;
$mail= new TripodMail;
$mail->sendMail($template,
/%hash);
In this case, "$template" is the name of the template file, and
"%hash" is a hash of variable mentioned in the template. The hash for the
template about should include a recipient, sender, subject, body, and signature
in the hash of variables. That hash would be built elsewhere in the script
that's calling the TripodMail module. For example, if this bit of code were in a
guestbook script, that script would collect information from a form (the place a
visitor actually signed the book). Along with building a new entry in your
guestbook, the script would also store the visitor's e-mail address in your hash
as "recipient," and your e-mail address as "sender."
One important thing
to note is that TripodMail is not the same thing as a mail program; any
ready-made script that uses a mail program will have to be significantly altered
before it will work. If you're writing your own scripts, keep this information
in mind if you plan to use TripodMail. The TripodMail.pm module also includes
information about how it works and how to call the methods.