Forms
Forms
can be compared to the paperforms you get to fill out
all the time.
A
form is simply an area on your website that is considered
by the browser to contain a set of information.
There really are no limits concerning
what you can do with the content of the form once it is
entered and submitted.
Usually
it is either sent as an email, as an input to a database
or as an input to a webpage.
In
any case, what really happens when a form is submitted,
is that a so called cgi-script (a program that runs on
a server) receives the data and then handles the data
the way the program was programmed to do.
Top
of page
CGI-SCRIPTS
A very popular cgi-script
to use in combination with forms is the "formmail.cgi",
a small program that simply forwards the content of the
form to a desired mailaccount.
Another
popular example of cgi-scripts used in combination with
forms is the "guestbook.cgi", a program that
adds the text submitted by the form to a html-page, which
will thus work as a guestbook.
The
triggy part about forms is, that usual you are not allowed
to run your own cgi-scripts on the server.
However,
most of the popular scripts are hosted for free around
the net. (for instance our
cgi-section also provides resources for free form
proccessing).
You
do not need to program your own cgi-scripts. In fact you
don't even need to have cgi-scripts on your own server
to use them. You can always use of the free cgi-scripts
if you cant run scripts on your own server or if you don't
know how to program them.
Note: Many
internetproviders hosts standard scripts such as formmail
and guestbookscripts, for their customers to use. Make
sure to check out which scripts are offered by your own
ISP (Internet Solution Provider).
The
reason internet providers usually do not allow customers
to run their own scripts is:
1)
that a bad script in the worst case can lay down
the entire server, and
2)
running scripts on a server, gives pretty good possibillities
for hacking the server, to gain access to sites
you really shouldnt have access to, and finally
3)
accepting customers scripts usually means accepting
way more administration than elsewise - this is
the reason that most providers that do allow customized
scripts charge higher prices.
|
To
summarize this section: All forms works in combination
with programs that runs on a server (cgi-scripts). If
you can noit run your own scripts, check out our section
of free remotely hosted scripts.
Top
of page
THE
FORM-TAG:
In order to tell the browser
where your form starts and where it ends you simply add
these tags in your HTML-codes:
Note:
Unlike a table, forms are not visible on the page.
The area of the page covered by the form can not
be seen by the visitors to the page.
Some pages has several forms that appears to the
visitor as if they were one, while others have one form
that appears as if it was several.
You
can add all kinds of HTML-tags between the <form>
and </form>-tags.
This means that a form can easily include a table or an
image along with the formfields mentioned underneath.
The
form entered above is useless for two obvious reasons:
First it contains no formfields- it is simply comparable
to a blank sheet of paper.
Second, it does not contain a recipient for
the form once it is submitted.
To
let the browser know what to do with the content of the
form, once it should be submitted we add properties to
the <form>-tag:
action=address
method=post
or method=get
address
is the
url of the cgi-script the content should be sent to.
post
and get
is simply two
different methods for submitting data to the script.
If
you are using a pre-programmed script (which we assumes
here) it is not important to understand the difference
between get and post.
In the description of the script
you are using it will be made clear whether the scripts
should be adressed using the one method or the other.
Below
is an example of a form that uses the script at
www.netkontoret.dk/cgi-bin/formmail.cgi
to
handle the content submitted from the form.
<form
method="post"
action=http://www.netkontoret.dk/cgi-bin/formmail.cgi>
</form> |
So
now that we have added an action to the <form>-tag,
we only need to allow the visitor to enter some information.
The next section explains how to do that.
Top
of page
FORMFIELDS:
The form mentioned above
is still useless.
It
will never be submitted since it does not contain a submit-button.
A submitbutton
is simply a button that, once clicked, starts the action
mentioned in the above section - which is: send the content
of the form to the cgi-program.
Furthermore,
our form still does not contain any form-fields.
Even if it had a submit-button, there really wouldnt
be anything to submit.
To
enter formfields and buttons to your from you should use
the <input>-tag.
To
insert a submit-button on your form, add these tags:
Top
of page
An
example:
Comming
soon