# HTML Forms
● The <form> Element
The HTML <form> element defines a form that is used to collect user input.
An HTML form contains form elements.
Form elements are different types of input elements, like text fields, checkboxes, radio buttons, submit buttons, and more.
● The <input> Element
The <input> element is the most important form element. This element can be displayed in several ways, depending on the type attribute.
● Text Input
<input type="text"> defines a one-line input field for text input.
● Radio Button Input
<input type="radio"> defines a radio button.
Radio buttons let a user select ONE of a limited number of choices.
Radio buttons let a user select ONE of a limited number of choices.
● The Submit Button
<input type="submit"> defines a button for submitting the form data to a form-handler.
The form-handler is typically a server page with a script for processing input data.
This is specified in the form's action attribute.
The form-handler is typically a server page with a script for processing input data.
This is specified in the form's action attribute.
● The <Action> Attribute
The action attribute defines the action to be performed when the form is submitted.
Normally, the form data is sent to a web page on the server when the user clicks on the submit button.
If the action attribute is omitted, the action is set to the current page.
Normally, the form data is sent to a web page on the server when the user clicks on the submit button.
If the action attribute is omitted, the action is set to the current page.
● The Method Attribute
The method attribute specifies the HTTP method ( GET / POST ) to be used when submitting the form data.
<form action="/action_page.php" method="get"> or
<form action="/action_page.php" method="post>
<form action="/action_page.php" method="get"> or
<form action="/action_page.php" method="post>
● When to Use GET
The default method when submitting form data is GET.
However, when GET is used, the submitted form data will be visible in the page address field.
● When to Use Post
Always use POST if the form data contains sensitive or personal information. The POST method does not display the submitted form data in the page address field.
POST has no size limitations, and can be used to send large amounts of data.
POST has no size limitations, and can be used to send large amounts of data.
● 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.
● Grouping Form Data with <fieldset>
The <filedset> element is used to group related data in a form.
The <legend> element defines a caption for the <fieldset> element.
The <legend> element defines a caption for the <fieldset> element.
No comments:
Post a Comment