|
Home >> FAQs/Tutorials >> XHTML Tutorials and Tips >> Index
XHTML 1.0 Tutorials - Understanding Forms and Input Fields
By: FYICenter.com
Part:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(Continued from previous part...)
What Are the Attributes of a FORM Element?
There are 3 commonly used attributes for a "form" element:
- "action" - Required attribute. Used to specify the URL of the form processing program.
- "method" - Optional attribute. Used to specify the form submission method: "get" or "post".
method="get" is the default setting.
- "enctype" - Optional attribute. Used to specify the input data encryption type.
enctype="application/x-www-form-urlencoded" is the default setting.
The URL of the form processing program is usually given to you by the Webmaster.
You just put it into the "action" attribute directly. If you specify an empty
"action" attribute, the URL of the current XHTML document will be used to submit the
form data.
From an XHTML document author's point of view, method="get" and method="post" have
no differences. Both of them will submit viewers input data to the submission program
specified in the "action' attribute.
The default setting for enctype="application/x-www-form-urlencoded" for most of
your forms. But you want upload files through a form, you need to use
enctype="multipart/form-data" and method="post".
Some examples of "form" element with different attributes:
<!-- Submitting to the URL of the current document -->
<form action=""></form>
<!-- Submitting to a perl program -->
<form action="/cgi-bin/survey.pl"></form>
<!-- Submitting to a PHP program -->
<form action="/survey.php" method="post"></form>
<!-- Submitting to a PHP program for file uploading -->
<form action="/upload.php" method="post"
enctype="multipart/form-data"></form>
(Continued on next part...)
Part:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|