Forms
E01 - The main things to know about HTML form code:
- E01a - (12:00)
- Forms are in many web sites. Some web pages have more than one form.
- Forms are usually used to send data to web servers and often include a request for a response in return when the button is pushed to submit the form (usually a Submit button).
- There are two methods of sending form data: get and post
- The get method is somewhat more secure than the post method because the form information is put into the http header which is not normally seen (although it can be). For information about secure connections: TSL/SSL and HTTPS
- The post method is used by search forms to enable the visitor to save the search.
- This is possible because the post method encodes the information into the url. Encoding does not mean encrypting - it means that the search terms are made a part of the url sent back to the server when the form is sent.
- The information sent is vulnerable and therefore this method ought to be avoided for sensitive data.
- Following is an example of encoding created by Google:
- The google site url is simply this:
http://www.google.com/
- However, after entering and then submitting the terms HTML & CSS, the url of Google changes, additional information is added and sent to the Google web server:
http://www.google.com/search?source=ig&hl=en&rlz=&=&q=HTML+%26+CSS&btnG=Google+Search
- The area that I've bolded in the url could be interpreted as follows:
- q=query (search for)
- The string (sequence of characters) HTML, and ( + ) ...
- %26 refers to the unicode hexadecimal number of the ampersand (&) character (glyph). Use this site to convert and ampersand into its url encoded equivalent to confirm.
- The series of characters CSS
- E01b - (9:04)
- Forms consist of form controls (also called objects) such
as checkboxes, radio buttons, and submit
buttons.
- All form controls are nested within a pair
of form tags.
- There are usually other tags within the opening and closing form tags.
- Each control in a form has a name attribute
that is used for database purposes. The label
text that appears visible to the viewer need
not conform to the name attribute.
- Most form controls have a value.
- When a visitor completes and submits a form:
- Each control name is coupled with the visitor's selected value.
- The result is referred to as a name-value pair.
- An example would be: name=Dan
- The name-value pairs are sent to a web server, which will then usually send the information to a database server. A response will often be sent back to the sender.
- For
those familiar with databases, a name-value pair is the equivalent
of a field name and a record's entry into
that field (value).
- The tags for form
controls, their attributes, and their associated code use terms that are usually obvious.
- They are often referred to as input and have the type attribute.