In this form your goal is to obtain contact information from your visitors. The information you want to collect is their name, address and email address. This is a perfect place to use text boxes which contain one line of text.
Since you are creating a form you will need the <form> tag. There are a number of important attributes that go with this tag. The first is the method attribute. You have two choices for this attribute, POST or GET. The GET method adds the information provided by the user to the actual web page URL. The CGI script then extracts this data from the appended URL. The advantage of this method is that you can bookmark the URL and save the data with it. The disadvantage is the amount of data you can send and the fact that the data is clearly visible in the address bar. To see an example of this type of method go to google and perform a search. Once you hit the search button look at the information in the address bar. You should be able to see all the information you placed in the text box before hitting the search button. If you were sending private or sensitive information this would not be a suitable method.
The POST method sends a data file to the server. The data file that is sent contains a name or label and a value for each piece of information that the user enters. The name of a data field must match the name in the CGI script so keep that in mind when creating forms. The advantage of the POST method is that the data is not clearly visible and you are not limited in the amount of data you can send.
In this example you will use the POST method so your form tag will be <form method="POST" >
The next attribute of the form tag is the ACTION tag. This tag indicates the location of the CGI script on the server that will handle the data from this form. In our case the script is a php script located on another server. Here is what your action tag should look like: <form method="POST" action="http://www.techdodge.com/php/handle_form1.php"> If you were running this web page from the server that contained this file and it was in the same directory as this web page then the action would look like this: action="handle_form1.php". Since you are not running a server on your workstation you must tell the web page where to send the data and what file will handle it. In this case the file is found on the server hosting the techdodge web site. Your data will be sent to this site and the server will send a response back to you once the data has been processed.
So far you have completed the form tag attributes as follows:
<form method="POST" action="http://www.techdodge.com/php/handle_form1.php">
Next comes the text boxes. Use the Form Attributes
page and any other resources to create the following text boxes.
Be sure that each textbox and each text area has a name value. The reason the
name value is so important is because this is the value that the CGI script
is looking for so the two must match. Here is how your name values should appear
for each text box:
Textbox - Name Value
Name - name
Street Address - address
City - city
Street - street
State - state
Zip Code - zip
Email Address - email
Comments - comments
Your page should look like this:
If you would like to receive monthly emails about our site complete the following form:
Name: ___of course a text box will go here not a line__
Street Address:_____________________
City:___________________ State:________________ Zip Code:______________
Email Address:_______________________________
Comments: a text area will go here so multiple lines of text can be entered.
The last thing to include on this form is the submit and reset buttons. These are created using the <input> tag.
Once you have created your page and it works demonstrate the submission of
your form for teacher check.
Back to Wednesday