Now that there is some background information on forms, let’s look at actually building some, and what goes into it.
Form Creation
First you should add form tag <form>
. The form tag has several attributes which will allow you to modify how the form works. The first two are usually used. However, if they are omitted, they do have defaults.
- action – the location (URL) of the form processor. If you leave action blank, it will send the file to your current location.
- method – how information will be sent from one location another. There are two main types.
- get – the form information is placed into the URL of the processor.
ex: http://access2learn.com/form.php?name=walter+wimberly
This also runs the risk of making the URL too long, as URLS can only be 4,000 characters total.
It also makes things like passwords, credit card numbers, and similar private information unsafe as they are posted in clear view to anyone shoulder surfing. - post – the form information is placed into the HTTP headers so they aren’t seen by people. This adds a very basic level of security for your users. Likewise, it doesn’t have the 4K limit in length. So now you don’t have to worry about how many fields are in your form, and you can even upload files.
- get – the form information is placed into the URL of the processor.
There are some lesser known/used attributes that are also available. These include:
- id– used if you are using JavaScript to modify the tags
- target – if you want to send the form to open another window. (Because I know you aren’t using frames are you?) It is assumed that it is going to the same frame if left blank
- encode – if you need to encode your data a certain way
- class – if you want to apply styles, or add a sub style to the class. Some front end CSS frameworks use this.
In it’s most basic format, a form on an HTML page looks like.
<form method="GET" action="//access2learn.com/form.php">
</form>
However, this doesn’t have any associated fields or a submit button to process it. Therefore, we need to add fields.
Building HTML Forms was originally found on Access 2 Learn