A simple HTML form
The <form> element
This element defines the form used in a web page to collect user input.It is used as below:
<form> <!--form elements --> </form>
Let us see all the elements one by one,
- The <input> element -The <input> elements can be of different types depending upon the type attribute.The various types are
<input type="text" /> Defines a one-line text input field <input type="radio" /> Defines a radio button (for selecting one of many choices) <input type="submit" /> Defines a submit button (for submitting the form)
- Action attributes-The action attribute defines the action to be performed when the form is submitted.It is used as
- Method attribute-The method attribute specifies the HTTP method (GET or POST) to be used when submitting the form data
<form action="scanfcode.php" method="get"> <!--or--> <form action="scanfcode.php" method="post">
The GET method-The GET method id the default method for submitting a form.Bu using GET method the data submitted over the form is visible in the address file like,
The POST method-POST method is used whenever more sensitive and important information is submitted in a from. The information can be passwords or account numbers.The information sent using POST is not visible in the address bar.Large amounts of data can be sent over POST.It has no size limitations.
The name attribute-Each input field must have a name attribute to be submitted.If the name attribute is omitted, the data of that input field will not be sent at all.
<form action="scanfcode.php" method="post"> First name:<br> <input type="text" name="firstname" value="Minnie"> <br> Last name:<br> <input type="text" name="lastname" value="Gupta"> <br><br> <input type="submit" value="Submit"> </form>