HTML Form ControlsAs you already know, HTML form controls are used to obtain user input. We played with HTML form controls using JavaScript, but we couldn't do much with the data entered in the controls. Now, we get to pass the form control data from page to page. This assignment will allow you to use various types of form controls such as text fields, password fields, text areas, check boxes, and radio buttons. You will input data and pass the data to another page. Remember that all controls should be included within the <form> tag. The <form> tag should include a method attribute and an action attribute. In addition the <form> tag should include submit and reset buttons. Here's an example of a form which includes a text field control:
<form name="form" method="post" action="ProcessTextField.php"> Notice that the action attribute is set to 'ProcessTextField.php'. This means that, upon hitting the submit button, all form data is sent to the 'ProcessTextField.php' page. The data is actually sent with an array variable named $_REQUEST. $_REQUEST holds all values submitted on a form. If you have ten form controls on a form, you will have ten values in the $_REQUEST array. This is create automatically. Once the form is submitted, the 'ProcessTextField.php' page is responsible for processing the form data. For example, you can get the value of the above text field by using the $_REQUEST array variable. The following code prints the message sent through the form control: Your name is:<?php print($_REQUEST["txtname"]);?>
Here's another hint. The following two pages consist of a form page and the process page. The form's action attribute, in the form tag, directs the user to the 'ProcessTextField.php' page and the data is printed.
Here are additional control examples linked to their respective process pages:
You assignment is to create the pages to demonstrate you ability to create form controls and the pages to process form controls and display form data. You will create an Assignment047 page with links to Text Field, Password Control, Text Area, Check Box, Radio Buttons, Drop-Down Box, List Box, and two All Conrols pages. Each page will include a form and will submit to its own processing page. This assignment will consist of 19 pages! Goodluck! |