<< .. Go to : : Home : : Exercise 5 : : Demo 5A : : Demo 5B : : Demo 5C : : Demo 5D : : TAGS : : All Class Demos .. >>

Exercise 7 Demo: Part A : Forms - A More Complex Version

Setting Up a Form When You Have Your Own URL and Space on a Server.

A form is created using the <form> </form> tags. EVERYTHING in a form must go between these two tags.

A Form itself is pretty simple - just interactive buttons to push, pulldown menus and boxes to fill with information. A simple form can be submitted through email. But the other real part of a form is an application or script located on the server itself, that makes the form work without having it automatically open the users email.

Once you have your own URL and space on a server this would be the more correct way to send form data using more complex code. If you have access to a server with appropriate CGI scripts (ask your web host or the tech dept), use this code:

<form method="post" action="http://www.servername.com/cgi-bin/script.name" enctype="text/plain">
<input type="hidden" name="recipient" value="username@emailaddress.com">
<input type="hidden" name="subject" value="Form Name">
.

Let's look at this code a piece at a time :

<form method="post" action="http://www.servername.com/cgi-bin/FormMail.pl" enctype="text/plain">

  • The METHOD attribute is the same as the first example.
  • The ACTION value specifies the server location of the script which will handle the data. It is almost always an absolute URL with a "cgi-bin". The "cgi-bin" is a location on a remote server which stores many different scripts that do many things.
  • The "/" separates the actual name of the CGI script being used. The script will tabulate the data and send it to the address specified in the next line of code.
  • The enctype attribute is also the same as the first example.

<input type="hidden" name="recipient" value="cfaulk7@cox.net">

The next element is input. We'll look at input types in more detail in Part B of the demo, but in this example, <input> has the following attributes:

  • type="hidden" - the viewer cannot see it.
  • name="recipient" - tells the CGI script that the results are going somewhere else.
  • value="cfaulk7@cox.net" - the email address - The CGI script sends the tabulated results of the form to me by email.

<input type="hidden" name="subject" value="Feedback Form">

This line of code creates the subject line of the email you receive the information in.


The correct way to write the <input> tag in XHTML is :

<input type="hidden" name="recipient" value="username@emailaddress.com" />
<input type="hidden" name="subject" value="FormName" />


In the next three parts of this demo we'll add several different types of data input types. After finishing all three demos, don't forget to close your form tag.

</form>

For more about using Links go to Part B of Demo 5.

Go back to the Exercise 5 page.

© Claudia Faulk. Created in 2008. Updated 1.12