Web Design Beginning Web Page Design Advanced Web Site Design Web Site Management Professor Higgins Web Design Resources
     

CSC 112 - Lesson 4

Management Tools for feedback

Many visitors to your web site will undoubtedly want to contact you. Some will place orders online without any additional information but others will want to contact you.

An easy way to provide your visitors with a link that will open up their email program with your email address in the send box is to use a mailto hyperlink. You simply use the following code:

<A HREF="mailto:you@yourhost.com">email me</A>

This code is the same as adding a hyperlink to your document except instead of typing in a domain name or web page name, you type in "mailto:" with your email address after it.

You can also add other parameters to your email like the subject or even the message. Here are a few examples:

Email to two or more recipients
(separate the email addresses with a semicolon)

<A HREF="mailto:person1@students.modemswitch.com; person2@students.modemswitch.com">Email Us</A>

Send a copy with the address in the cc field

<A HREF="mailto:person1@students.modemswitch.com?cc= person2@students.modemswitch.com">Email Us</A>

Send a blind copy

<A HREF="mailto:person1@students.modemswitch.com?bcc= person2@students.modemswitch.com">Email Us</A>

A message in the subject field

<A HREF="mailto:person1@students.modemswitch.com?subject=Email with subject Example">Email Us</A>

A message in the body of the email

<A HREF=
"mailto:person1@modemswitch.com?body=Email with message in the body example">Email Us</A>

You can fill in multiple fields if you wish also

<A HREF="mailto:person1@students.modemswitch.com?subject=Email with subject Example&cc=person2@modemswitch.com&body="here is the body text">Email Us</A>

Note: In these examples the code is wrapped on the page because of formatting. Anytime you add parameters to any tag, you should be sure that everything between double or single quotation marks in on a single line. If everything between the quotation marks is not on one line in your code, you are likely to get an error message and your links may not work.

Many web designers neglect to use parameters when they use the mailto tag on their web pages but those who take the extra time to add them create more professional and functional sites by doing so. Use the parameters in your mailto tags. Your visitors will think more of you if you do.

The advantages of using the mailto A link are the visitor uses his or her default email program, which they are undoubtedly familiar with. The message will be saved in the users "sent mail" file and can be referred to for future reference. The disadvantage of the mailto link is the inverse of the advantage. If the visitor is on any computer other than his or her own, the email program will be set up for someone else or possibly not set up at all. The computers at Parkland are a good example of this. Since the email programs are not configured on these computers, you can't use mailto links. The users default email program must be defined before a mailto link will work.

To get around this problem, most web designers use forms to send email from their web sites by their visitors.

Email Forms

In the control center on the class web site at: http://www.students.modemswitch.com/admin/ , we have installed a cgi program called FormMail that allows you to use an email form without doing any programming or changing any parameters in a cgi-file. With FormMail, all you need to do is to add your form to you web page. Within the form, you set all the parameters that you need to receive email from you visitors formatted to your specifications.

When you go to the control center, you will notice a listing called "FormMail Script" with two buttons: Docs and FormMail. When you click on the FormMail button, you will see:

The FormMail script is ready for use.
Add the following lines to your web page (the one with the form) :

<form method="POST" action="/cgi-bin/FormMail.pl">
<input type="hidden" NAME="recipient" value="me@mydomain.com">
<input type="hidden" NAME="redirect" value="http://students.modemswitch.com/thankyou.html">
You can replace me@mydomain.com by any E-mail address you wish. The URL for the 'redirect' line can also be changed. This is the URL people are sent to after the complete the form and click the button.

Other (optional) variables can be used :

from = E-mail address to reply to (person filling out form)
subject = Subject for the message

To make certain fields required, add the following :
<input type="hidden" name="required" value="field1,field2">
In the above example, 'field1' and 'field2' are required fields.
To use a customized error page, add variable 'missing_fields_redirect'.

This is really just about all you need to know to make the script work for you. You will need to make a couple of html pages that your users will be "redirected" to after they complete your form or if they make an error by not completing a required field. Of course, you need to change the email address to you email address too. The only other things that you really need to know about is the print_config attribute. Even though the documentation calls this an optional tag, you need it in order for your fields to be printed (displayed) in the body of the email message you receive Here is the info about it:

Field: print_config

Description: print_config allows you to specify which of the config variables you would like to have printed in your e-mail message. By default, no config fields are printed to your e-mail. This is because the important form fields, like email, subject, etc.
are included in the header of the message. However some users
have asked for this option so they can have these fields printed
in the body of the message. The config fields that you wish to
have printed should be in the value attribute of your input tag
separated by commas.

Syntax:
If you want to print the email and subject fields in the body of
your message, you would place the following form tag:

<input type=hidden name="print_config" value="email,subject">

Complete Form Example

Here is an example from the email form that I use on this web site:


<form method="post" action="/cgi-bin/FormMail.pl">
<input type="hidden" name="recipient" value="rhiggins@robhiggins.com">
<input type="hidden" NAME="redirect" value="/parkland/thankyou.html">
<input type=hidden name="print_config" value="realname,from,subject,comments,
REMOTE_HOST,HTTP_USER_AGENT,REMOTE_ADDR">
<input type=hidden name="required" value="from,realname,comments">
<input type=hidden name="env_report" value=
"REMOTE_HOST, HTTP_USER_AGENT, REMOTE_ADDR">
<input type=hidden name="missing_fields_redirect" value="/parkland/error.html">
<table border="0" width="300">
<TR><TD><b>Name</b> &nbsp;</TD><TD>
<input type="text" name="realname"></TD></TR>
<TR>
<TD><b>Email</b> &nbsp;</TD><TD>
<input type="text" name="from"></TD><TR></TABLE>


<p><font face="Arial, Helvetica, sans-serif">Message Title:
<input type=text name="subject">
</font></p>
<p><font face="Arial, Helvetica, sans-serif">Comments: <br>
<textarea name="comments" cols="30" rows="5" wrap="VIRTUAL"></textarea>
</font><font face="Arial, Helvetica, sans-serif"><Br>
<input type="submit" name="Submit" value="Submit">
</font> </p>
</form>

Here is the information that is listed under FormMail docs at the control center:

Form Configuration:
===================

The action of your form needs to point towards this script (obviously), and the method must be POST in capital letters. Below is a list of form fields you can use and how to implement them.

Necessary Form Fields:
======================

There are only two form fields that you must have in your form, for FormMail to work correctly. This is the recipient and the redirect fields.

Field: recipient

Description: This form field allows you to specify to whom you wish for your form results to be mailed. Most likely you will want to configure this option as a hidden form field with a value equal to that of your e-mail address.

Syntax:
<input type=hidden name="recipient" value="email@your.host.com">

----------------------------------------------------------------

Field: redirect

Description: If you wish to redirect the user to a different URL, rather than having them see the default response to the fill-out form, you can use this hidden variable to send them to a pre-made HTML page.

Syntax:
To choose the URL they will end up at:
<input type=hidden name="redirect"
value="http://your.host.com/to/file.html">

To allow them to specify a URL they wish to travel to once the
form is filled out:
<input type=text name="redirect">


----------------------------------------------------------------

Optional Form Fields:
=====================

Field: subject

Description: The subject field will allow you to specify the subject that you wish to appear in the e-mail that is sent to you after this form has been filled out. If you do not have this option turned on, then the script will default to a message subject:

WWW Form Submission

Syntax:
If you wish to choose what the subject is:
<input type=hidden name="subject" value="Your Subject">

To allow the user to choose a subject:
<input type=text name="subject">

----------------------------------------------------------------

Field: from

Description: This form field will allow the user to specify their return e-mail address. If you want to be able to return e-mail to your user, I strongly suggest that you include this form field and
allow them to fill it in. This will be put into the From: field of the message you receive. If you want to require an email address with valid syntax, add this field name to the 'required' field.

Syntax:
<input type=text name="from">

----------------------------------------------------------------

Field: required

Description: You can now require for certain fields in your form to be filled in before the user can successfully submit the form. Simply place all field names that you want to be mandatory into this field. If the required fields are not filled in, the user will be notified of what they need to fill in, and a link back to the form they just submitted will be provided.

To use a customized error page, see 'missing_fields_redirect'

Syntax:
If you want to require that they fill in the email and phone
fields in your form, so that you can reach them once you have
received the mail, use a syntax like:

<input type=hidden name="required" value="email,phone">

----------------------------------------------------------------

Field: env_report

Description: Allows you to have Environment variables included in the e-mail message you receive after a user has filled out your
form. Useful if you wish to know what browser they were using,
what domain they were coming from or any other attributes
associated with environment variables. The following is a short
list of valid environment variables that might be useful:

REMOTE_HOST - Sends the hostname making a request.
REMOTE_ADDR - Sends the IP address of the remote host making
the request.
REMOTE_USER - If server supports authentication and script
is protected, this is the username they have
authenticated as. *This is not usually set.*
HTTP_USER_AGENT - The browser the client is using to send the
request.

There are others, but these are a few of the most useful. For
more information on environment variables, see:

http://www.cgi-resources.com/Documentation/Environment_Variables/

Syntax:
If you wanted to find the remote host and browser sending the
request, you would put the following into your form:

<input type=hidden name="env_report" value="REMOTE_HOST,
HTTP_USER_AGENT">

----------------------------------------------------------------

Field: sort

Description: This field allows you to choose the order in which you wish for your variables to appear in the e-mail that FormMail generates. You can choose to have the field sorted
alphabetically or specify a set order in which you want the
fields to appear in your mail message. By leaving this field
out, the order will simply default to the order in which the
browsers sends the information to the script (which is usually
the exact same order as they appeared in the form.) When
sorting by a set order of fields, you should include the phrase
"order:" as the first part of your value for the sort field, and
then follow that with the field names you want to be listed in
the e-mail message, separated by commas.

Syntax:
To sort alphabetically:
<input type=hidden name="sort" value="alphabetic">

To sort by a set field order:
<input type=hidden name="sort" value="order:name1,name2,
name3,etc...">

----------------------------------------------------------------

Field: print_config

Description: print_config allows you to specify which of the config
variables you would like to have printed in your e-mail message.
By default, no config fields are printed to your e-mail. This
is because the important form fields, like email, subject, etc.
are included in the header of the message. However some users
have asked for this option so they can have these fields printed
in the body of the message. The config fields that you wish to
have printed should be in the value attribute of your input tag
separated by commas.

Syntax:
If you want to print the email and subject fields in the body of
your message, you would place the following form tag:

<input type=hidden name="print_config" value="email,subject">

----------------------------------------------------------------

Field: print_blank_fields

Description: print_blank_fields allows you to request that all form fields
are printed in the return HTML, regardless of whether or not
they were filled in. FormMail defaults to turning this off, so
that unused form fields aren't e-mailed.

Syntax:

If you want to print all blank fields:
<input type=hidden name="print_blank_fields" value="1">

----------------------------------------------------------------

Field: title

Description: This form field allows you to specify the title and header that
will appear on the resulting page if you do not specify a
redirect URL.

Syntax:
If you wanted a title of 'Feedback Form Results':
<input type=hidden name="title" value="Feedback Form Results">

----------------------------------------------------------------

Field: missing_fields_redirect

Description: This form field allows you to specify a URL that users will be
redirected to if there are fields listed in the required form
field that are not filled in. This is so you can customize an
error page instead of displaying the default.

Syntax:
<input type=hidden name="missing_fields_redirect"
value="http://your.host.com/error.html">

----------------------------------------------------------------

Any other form fields that appear in your script will be mailed back to
you and displayed on the resulting page if you do not have the redirect
field set. There is no limit as to how many other form fields you can
use with this form, except the limits imposed by browsers and your server.

----------------------------------------------------------------


----------------------------------------------------------------