HTML Forms
Action Method and Name Properties
When we created a form we used code similar to the following:
The action attribute sets the details of which file will process the form.Â
The method attribute states how the form will be submitted ( GET or POST).Â
The name property of the inputs will be used by the php file to access their contents.
Option Buttons and Select Elements
Option buttons and Select elements ( drop down boxes) are slightly different in that they can supply different values as the user does not type anything.
Select Example
The code below creates a drop down box with all of the months listed in it.Â
The user would be presented with this control with the options as shown below.
You will notice that the value and the text displayed can be different.
The value selected would be accessed using the following PHP code:
$month = $_POST['month'] ;Â
Option/Radio Buttons
Again with radio buttons the user does not enter any value, they select an option. The code below would provide the user with 3 radio butons to choose from:
You will notice that each of the radio buttons has the same name. And again the value property and the text displayed to the user do not have to be identical
This would render as the screenshot above.