4.
Creating and Validating Forms
Text box:-A text input field allows a user to enter a
single line of text.
• When to use GET?
• Information sent from a form with the GET method is visible to
everyone (all variable names and values are displayed in the URL).
GET also has limits on the amount of information to send. The
limitation is about 2000 characters.
• However, because the variables are displayed in the URL, it is possible
to bookmark the page. This can be useful in some cases.
• GET may be used for sending non-sensitive data.
• Note: GET should NEVER be used for sending passwords or other
sensitive information!
• When to use POST? :-Developers prefer POST for
sending form data.
• Information sent from a form with the POST
method is invisible to others (all names/values are
embedded within the body of the HTTP request)
and has no limits on the amount of information to
send.
• Moreover POST supports advanced functionality
such as support for multi-part binary input while
uploading files to server.
• However, because the variables are not displayed
in the URL, it is not possible to bookmark the page.
When the user fills out the form above and clicks the submit button,
the form data is sent for processing to a PHP file named
"welcome.php".
Introduction to radio buttons :
To create a radio button, you use the <input> element with the
type radio.
Radio button let a user select only one of a limited number of
choices.
For example:
<input type="radio" name="contact" id="contact_email"
value="email" />Code language: HTML, XML (xml)
you can place the radio button within a <label> element like
this:
<label> <input type="radio" name="contact_email"
value="email"> Email
</label>
• Check box:- Let the user select one or more
options of a limited number of choices.
• The <input type="checkbox"> defines a
checkbox.
• The checkbox is shown as a square box that is
ticked (checked) when activated.
• Checkboxes are used to let a user select one
or more options of a limited number of
choices.