The form Element

All forms begin with the form element:



The form element has two required attributes you'll need to add to it for the form to function at all:

  • method This attribute defines which way the form is going to communicate with your web server. The value options are get and post.

  • action The action attribute provides the correct path to where the form script is processed (see Example 5-1).

Example 5-1. Adding method and action attributes and values to a form element

<form method="get" action="">



You'll need to check with your ISP to find out the preferred method with any form-processing scripts it provides. What's more, many ISPs provide a number of form-processing scripts, but not all scripts will be as robust as what your needs might require.

If you're looking to create a simple contact form, you shouldn't have any problems. However, if it's a shopping cart script, for example, that's going to require additional programming and customization. It's important to point out that not all service providers allow you to have advanced scripts, so you'll really need to do your homework in advance to get the service you require.

At this point, the markup you've created will not do anything in and of itself. Forms work based on the concept of controls. Controls are the default boxes and buttons that appear as a result of your HTML form markup.