Cover by Ben Henick

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

Basic Form Structure, Presentation, and Behavior

Those of you coming to this book from a design or editorial background may be anxious to know: how the heck do forms work on a round-trip basis? (That was my first question when I started on my first big web application project in 1999, anyway.) There are also some oddities of form markup and behavior that are well known to experienced developers, but might not be familiar to all readers.

Form-Originated get Requests

If you’ve spent much time around form markup, you’ve surely noticed that every form element has an action attribute, and every field element has a name attribute. The latter are paired with their companion value values, and encoded by the browser in the following manner:

content=Hello+World%21

That’s the literal submission to the web server, which in normal language reads “Hello World!”

There are two reliable methods for sending this data to the server: get and post. get appends the encoded data to the URI specified in the form’s action attribute, resulting in a destination such as:

http://example.com/printmystuff.php?content=Hello+World%21

Note the literal ? that separates the data submission from the name of the requested resource—in this case, a script named printmystuff.php in the root folder of the host’s public filesystem.

Additional name/value pairs are separated by literal & (ampersand) characters, as follows:

http://example.com/printmystuff.php?content=Hello+World%21&color=red&size=xx-large

Even though the resulting URIs ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required