Working with form attributes

Sending a form to the server

In order to submit the form to the server for further processing, you must specify where to send the form and how to send it. This can be done by adding the following attributes to the <form> tag:

<form action="URL" method="option">

where URL specifies the URL of the server script responsible for processing of the form, and option is either get or post.

If get method is used, then the form data will be appended at the end of the URL specified in the action field. For example, if the script URL is http://cs2.uwsuper.edu/cgi-bin/CheckData, then the correct options for the <form> tag are

<form action="http://cs2.uwsuper.edu/cgi-bin/CheckData" method="get">

If the form contains just one input text field specified by <input type="text name="test" value="Outline">, then the resulting URL after submitting this form will be http://cs2.uwsuper.edu/cgi-bin/CheckData?test=Outline.

We will use the post method, which send the form data in a separate data stream, called "standard input". Therefore, for submitting the above form the right options for the <form> tag are

<form action="http://cs2.uwsuper.edu/cgi-bin/CheckData" method="post">




Using the "mailto" action

Instead of using a CGI script you can email the form data to a specific address by using the mailto action. The syntax of the mailto action is:

<form action="mailto:e-mail_address" method="post" enctype="text/plain">

For example, if your email address is jbrown@students.uwsuper.edu, then the right form attributes would be:

<form action="mailto:jbrown&#64;students.uwsuper.edu" method="post" enctype="text/plain">

Here the symbol '@' is replaced with its entity &#64;.