Creating a Form

Forms are the most common type of interaction between users and web applications, providing a much wider set of possibilities for user input than simple hypertext linking. HTML provides a set of components for collecting information from users, which HTTP then transmits to the server using your choice of methods. On the server side, your application processes the information sent from the form and generally replies to the user as you deem appropriate.

Creating the form is a simple matter of editing our original brochure to turn it into a form. We have to resist the temptation to fool around, making our script more and more beautiful. We just want to add four fields to capture the number of copies of each card the customer wants and, at the bottom, a field for the credit card number.

The catalog, now a form with the new lines marked:

<!-- NEW LINE - <explanation> -->

looks like this:

<html> <body> <FORM METHOD="POST" ACTION="cgi-bin/mycgi.cgi"> <!-- see text --> <h1> Welcome to Butterthlies Inc</h1> <h2>Summer Catalog</h2> <p> All our cards are available in packs of 20 at $2 a pack. There is a 10% discount if you order more than 100. </p> <hr> <p> Style 2315 <p align="center"> <img src="bench.jpg" alt="Picture of a bench"> <p align="center"> Be BOLD on the bench <p>How many packs of 20 do you want? <INPUT NAME="2315_order" > <!-- new line --> <hr> <p> Style 2316 <p align="center"> <img src="hen.jpg" alt="Picture of a hencoop like a pagoda"> <p align="center"> Get ...

Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.