(from Matt's Script
Archive)
FormMail is a generic WWW form to e-mail gateway, which will parse the
results of any form and send them to the specified user. This script has
many formatting and operational options, most of which can be specified
through the form, meaning you don't need any programming knowledge or multiple
scripts for multiple forms. This also makes FormMail the perfect system-wide
solution for allowing users form-based user feedback capabilities without
the risks of allowing freedom of CGI access.
It accepts forms via either GET or POST methods, and
allows e-mail to addresses outside our server's domain.
<FORM METHOD="POST" ACTION="cgi-bin/FormMail.pl">
FormMail.pl install:
(1) We can install FormMail.pl into your account at your request.
Just contact technical support.
(2) Alternatively you may install FormMail.pl yourself. Doing
so is also good practice in how to configure forms and use your server's
cgi systems. If you would like to try a self-install, which is very
easy, then this is the procedure.
-
Download formmail.tar by clicking on the link.
-
Upload formail.tar via FTP (in binary mode not ascii) into your cgi-bin
directory
-
Now you have to unpack it
so go into your Telnet SSH shell and
run the following command from the cgi-bin directory:
tar -xf formmail.tar
-
The file will unpack your files.
-
A new directory has been created called formmail. Go to it:
cd formmail
-
Here you will see that your FormMail.pl script is now present along with
a help file. However this is in the wrong directory. We need
to move it to the cgi-bin directory, not the cgi-bin/formmail directory.
-
You need to move FormMail.pl to the lower directory (cgi-bin). The
easiest way to do this is to copy it in ascii mode via FTP form one directory
to the other.
-
Once copied return to the cgi-bin directory (command cd.. ) and you should
see a copy of FormMail.pl there.
-
Set the file's permission so it is executable on the server. To do
this use the chmod command as follows:
chmod 755 FormMail.pl
-
Now you need to setup the script. If you edit it on your computer
make sure to download and upload it in ascii mode. In pico or a pure
text editor go into FormMail.pl
-
The path to perl is already set to the correct path, no need to change
it
-
a few lines lower set $mailprog = '/usr/sbin/sendmail'; (this is
the path to sendmail)
-
Next we go to the referrers line. This is important. You must
put all the domains that you will use with the script in this line.
Normally just your domain name. The script will not send data back
to any domain that is not listed here for security reasons. For instance
if you will use the script to send data back to these two domains: yourdomain.com
and rabbit.com, then setup the referrers line as follows:
@referers = ('yourdomain.com','rabbit.com');
-
Save FormMail.pl
-
Your done and your an accomplished script installer!
-
You may elect to delete the old formmail.tar file if you want.
Using FormMail.pl
It accepts forms via either GET or POST methods, and
allows e-mail to addresses outside our server's domain. You can call
it from any HTML file through the following code:
<FORM METHOD="POST" ACTION="cgi-bin/FormMail.pl">
Please pay attention to upper and lower case above as it is important.
The following fields can be defined for FormMail.pl; only
the
recipient field is required:
-
recipient (required)
-
This field specifies the destination e-mail address for the form contents.
Example:
<INPUT TYPE="hidden" NAME="recipient" VALUE="address@domain.com">
See the note at the bottom of this section
if you are using an
email address here that is not hosted on your server.
-
subject
-
This field specifies the Subject line of the outgoing e-mail. If not given,
the default Subject is "WWW Form Submission". Example:
<INPUT TYPE="hidden" NAME="subject" VALUE="Some Subject
Line">
You can also allow the user to specify the Subject field:
<INPUT TYPE="text" NAME="subject">
-
email
-
This field specifies the return e-mail address of the user submitting the
form. If supplied, this should be a field filled in by the user. The e-mail
will be generated so that your mailer's reply function should go to this
address; if not supplied, the default is nobody@pair.com. Example:
<INPUT TYPE="text" NAME="email">
-
realname
-
This field specifies the real name of the user submitting the form. If
supplied, this should be a field filled in by the user. The e-mail will
be generated with this name in the headers. Example:
<INPUT TYPE="text" NAME="realname">
-
redirect
-
This field specifies the URL to which the user should be automatically
redirected after successful delivery of the form. If this is not specified,
a default response will be generated by the script. Example:
<INPUT TYPE="hidden" NAME="redirect" VALUE="http://domain.com/whatever.html">
-
required
-
This field allows you to specify that certain fields in the form are "required";
that is, that they may not be empty when the form is submitted. If any
of the specified fields are empty, the user will receive a warning, and
the form will not be submitted. Example:
<INPUT TYPE="hidden" NAME="required" VALUE="email,subject">
-
env_report
-
This field specifies a list of environment variables that should be submitted
along with the form contents. This is useful for recording, for example,
the IP address of the user submitting the form. Useful environment variables
to record include:
-
REMOTE_ADDR - IP address of the user's host
-
HTTP_USER_AGENT - name and version of the user's browser
Example:
<INPUT TYPE="hidden" NAME="env_report" VALUE="REMOTE_HOST,HTTP_USER_AGENT">
Note: case is important for environment variables.
-
sort
-
This field specifies how the fields submitted from the form should be sorted
in the outgoing e-mail message. By default, the fields are not in any particular
sort order (results are dependent on the user's browser). You may specify
"alphabetic" for straight alphabetic sorting (same as form.cgi,
described above), or you may specify the exact order with "order:". Examples:
<INPUT TYPE="hidden" NAME="sort" VALUE="alphabetic">
<INPUT TYPE="hidden" NAME="sort" VALUE="order:name,email,phone">
-
print_config
-
This field specifies that the formmail.pl control fields, normally
removed from the body of the outgoing message, be included for completeness.
Example:
<INPUT TYPE="hidden" NAME="print_config" VALUE="email,subject">
-
title
-
This field specifies the title for the default response page that is generated
by the script in absence of a redirect field. The default is "Thank
You". Example:
<INPUT TYPE="hidden" NAME="title" VALUE="Form Results">
-
return_link_url
-
This field specifies a URL that will appear on the default response page
that is generated by the script in absence of a redirect field.
This URL can be used to allow users to return to, for example, your home
page. Example:
<INPUT TYPE="hidden" NAME="return_link_url" VALUE="http://domain.com/">
-
return_link_title
-
This field specifies the text that will be used inside the link generated
when return_link_url is specified. Example:
<INPUT TYPE="hidden" NAME="return_link_title" VALUE="Return
to Home Page">
-
background
-
This field specifies the URL of a background image that will be used on
the default response page that is generated by the script in absence of
a redirect field. Example:
<INPUT TYPE="hidden" NAME="background" VALUE="http://domain.com/img/bkgr.gif">
-
bgcolor
-
This field specifies the background color that will be used on the default
response page that is generated by the script in absence of a redirect
field. Example (pure white):
<INPUT TYPE="hidden" NAME="bgcolor" VALUE="#FFFFFF">
-
text_color
-
This field specifies the text color that will be used on the default response
page that is generated by the script in absence of a redirect
field. Example (pure black):
<INPUT TYPE="hidden" NAME="text_color" VALUE="#000000">
-
link_color
-
This field specifies the unvisited link color that will be used on the
default response page that is generated by the script in absence of a redirect
field. Example (pure red):
<INPUT TYPE="hidden" NAME="link_color" VALUE="#FF0000">
-
vlink_color
-
This field specifies the visited link color that will be used on the default
response page that is generated by the script in absence of a redirect
field. Example (pure blue):
<INPUT TYPE="hidden" NAME="vlink_color" VALUE="#0000FF">
-
alink_color
-
This field specifies the active link color that will be used on the default
response page that is generated by the script in absence of a redirect
field. Example (pure green):
<INPUT TYPE="hidden" NAME="alink_color" VALUE="#00FF00">
Security check information:
Please note that the system only authorizes you to use this script from
your domain name for your security. IE, if someone off of your server
tries to hijack your FormMail.pl script for their use, it will refuse the
connection.
Ending the script:
Last but not least, end your script with:
<input TYPE="SUBMIT" VALUE="SUBMIT NOW">
<input TYPE="RESET" VALUE="RESET FIELDS"> (this is optional)
</form>
This script allows you to track and display the number of users
that visit your webpage. It is highly accurate. Of course you
can track your most popular pages just by using WEBALIZER in your control
panel, but this is another option. This script uses server side includes
which means any webpage it resides on must be called or renamed to end
with .shtml not .html. So if you want to put a counter on a page
called mypage.html, the page needs to be renamed mypage.shtml.
counter.pl install:
(1) We can install count.pl into your account at your request.
Just contact technical support.
(2) Alternatively you may install counter.pl yourself. Very easy.
Doing so is also good practice in how to configure scripts and use your
server's cgi systems. If you would like to try a self-install, which
is very easy, then this is the procedure.
-
Download textcount.tar by clicking on the link.
-
Upload textcount.tar via FTP (in binary mode
not ascii) to your httpdocs directory
-
Now you have to unpack it
so go into your Telnet SSH shell and
run the following command from the httpdocs directory:
tar -xf textcount.tar
-
The file will unpack your files.
-
A new directory has been created called textcounter. Go to it:
cd textcounter
-
Here you will see that your counter.pl script is now present along with a
few other files and a data directory which will store all user hit information.
-
Now we need to set some permissions. in the textcounter directory
issue the following commands:
chmod 777 data
and
chmod 755 counter.pl
-
Now you need to setup the script's variables. There are just a few.
If you edit it on your computer make sure to download and upload it in
ascii mode. In pico or a pure text editor go into counter.pl
-
Set the first line of the script to the correct perl path:
#!/usr/bin/perl
-
A little ways down set the data directory to:
$data_dir = "data/";
-
A little more down you will see a show link swtting. You should set
this
to your domain as follows so people hitting on the counter will be taken
to your homepage:
$show_link = "http://yourdomain.com";
-
Save counter.pl
-
Believe it or not your done!
-
You may want to read the readme file for other varible options which you
can utilize.
Using counter.pl
Using counter.pl is very easy. It automatically creates a counter
file for every page you put it on! All you have to do is the following:
(1) make sure any page you put it on is SSI enables, which means its name
ends in .shtml
(2) somewhere in that page's code insert the following code where you want
the counter to appear: (assuming you are calling it from your httpdocs directory):
<!--#exec cgi="textcounter/counter.pl"-->
(3) If the above is correct you should see a counter the next time
you load your page!