HTML and CSS Reference
In-Depth Information
or reports an error to the user. he CGI program is also responsible for doing
something with the user's input, such as performing calculations, updating
databases, or emailing the information to someone. It is beyond the scope of
this topic to teach CGI or database programming. However, there are free CGI
programs to format and email the user's input.
he form element has two important attributes: action and method . he
action attribute's value is the URL of the server resource that is sent the form's
contents appended to the HTTP request the browser generates upon form sub-
mission. he method attribute tells the browser how to send that input. If it has
the value "post" , the browser adds to the HTTP request header a name=value
pair for each input ield. If the method attribute has the value "get" , the browser
appends the name=value pairs to the end of the URL in the action attribute.
Most CGI scripts are written to accept post requests. Some CGI scripts also
accept get requests, but some reject get requests as a security precaution. A
typical form element looks something like this:
<form method="post" action="/cgi-bin/save_info.cgi">...</form>
he action attribute's value is a URL, and that can be a “mailto” URL such
as this:
<form method="post" action="mailto:info@example.com">...</form>
In this case, when the form is submitted, the browser opens a new email
message using the user's email program with the name=value pairs in the body
of the message.
he children of the form element create text input ields, selection menus,
checkboxes, radio buttons, and submit and reset buttons. For historical rea-
sons, most of this functionality is implemented through the input element and
the particular form depends on the value of its type attribute.
If an input element has a type attribute with the value "text" , it creates a
single line input ield. his code, for example:
<input type="text" name="fullname" size="60"/>
creates an input ield 60 characters wide. A browser accepts more than this
number of characters typed into the ield unless the input tag also includes a
maxlength attribute. Adding a maxlength attribute is a good idea just in case
the server-side CGI script neglects to check the input rigorously enough.
 
Search WWH ::




Custom Search