HTML and CSS Reference
In-Depth Information
This causes the browser to display a button with the default value of “Submit Query.”
Finally, you are ready to enter the closing form tag, </form> . A sample with all of the
XHTML for the form follows:
<form>
E-mail: <input type="text" name="CustEmail" id="CustEmail" />
<br /><br />
<input type="submit" />
</form>
Save your contact.html file. Test your page in a browser. It should look similar to the
page shown in Figure 9.4.
You can compare your work with the solution found on the student files in the
Chapter9/9.1 folder. Try entering some information into your form. Try clicking the
button. Don't worry if the form redisplays but nothing seems to happen when you click
the button—you haven't configured this form to work with any server-side processing.
Connecting forms to server-side processing is demonstrated in Section 9.5. In the next
section you'll take a detailed look at the elements and attributes used to create forms.
The Form Element
The <form> tag specifies the beginning of a form area on a Web page. Its closing tag,
</form> , specifies the ending of a form area on a Web page. There can be multiple
forms on a Web page, but they cannot be nested inside each other. The <form> tag can
be configured with attributes that specify what server-side program or file will process
the form, how the form information will be sent to the server, and the name of the
form. Attributes such as name , method , and action are used to configure these options.
These attributes are listed in Table 9.1. The most commonly used attributes are shown
in bold.
For example, to configure a form with the name of order , using the post method, and
invoking a script called order.php in a folder called cgi-bin on your Web server, the
XHTML is as follows:
<form name="order" method="post" id="order"
action="cgi-bin/order.php">
form elements go here . . .
</form>
FAQ
What's the difference between the get and post methods?
You should usually use post as the value of the method on your forms. When you use get as
the value the form data is appended to the end of the URL. This URL area (called the
HTTP_REFERER) can be captured and stored in Web site logs. You probably don't want your
visitor's form data showing up in someone else's Web server logs. This makes the get method
much less private than the post message, which sends the form data in the entity body of the
HTTP Request.
 
Search WWH ::




Custom Search