Forms

Section 1 - Introduction
Section 2 - Basics
Section 3 - Next Level
Section 4 - Advanced
      Fancy Lists
      Forms
         How forms are sent
         Input field
         Buttons
         Input types
         Fieldset
         For more help...
         You try it
      Advanced Tables
      Frames
      Style Sheets
      Image Maps
Section 5 - Publishing
Section 6 - Extras
Appendices
Time to learn how to do a simple form. You have already seen the beginning and ending tags. They are simply <form> and </form>. This form will do absolutely nothing. In order to get it to work, you need a place where the user can fill things out. This is called an input field. Here's how that looks:

Code
<form>
This is just text. <input>
</form>
What you see
This is just text.
In the text area of this page, you can actually type. Try it. If you hit enter, nothing happens though. The page might reload, but that's it. You need to tell your form what to do. This is contained within the form tag.

You must tell the form what method to use when functioning. there are two methods. The form may either get something, or send something. Sending something is called posting. Let's talk about a form that will send an e-mail to you. This is an example of posting. Now you can modify your first tags.
<form method="POST">
     <input>
</form>
You've told it to post, but you haven't told it where to post. You need to give your form an action. If you are using a CGI script, you'd tell it to go to the CGI script. If you want it to send the form to you in e-mail, you'd tell it to do that action. Here's how that looks:
Code
<form method="POST" action="mailto:sciencepageofmystery@hotmail.com">
This is just text. <input>
</form>
What you see
This is just text.


This is about as simple a form as you can get. I don't really recommend using mailto: because it has some really bad problems. First of all, it opens your e-mail up to a host of viruses. Second, it doesn't always work. Problems also include having the e-mail get lost in cyber-space. Another is that the person can't use it because they don't have e-mail set up on their computer.

There is a beautiful solution to this. As stated by http://www.isolani.co.uk/articles/mailto.html:
One common punt by the inexperienced web-designer is that his web-host doesn't offer CGI facilities, so he is forced to use a mailto:. There is a reliable alternative for this problem, apart from moving to a different web-host. This alternative is the remotely-hosted formmail script - which is a script that is hosted on someone else's box. Two sites allow web-designers to use these scripts freely, they are Response-O-Matic and Freedback.
Geocities has a way around this problem. When you want to CREATE AND UPDATE your page, you can find a list of ADD-ONS which you can tack onto your site. By using and modifying EMAIL FORMS, you can use the CGI of Geocities to get things mailed to you.

That sounds good... when you're ready for it. One problem though, the user can't actually send this form to you. To do that, you would need buttons. That's our next lesson.
Back Home Forward