HTMLForm 3
HTMLForm 3
OVERVIEW
HTML Forms are required, when you want to collect some data from the
site visitor. For example, during user registration you would like to
collect information such as name, email address, credit card, etc.
A form will take input from the site visitor and then will post it to a
back-end application such as PHP script . The back-end application will
perform required processing on the passed data based on defined
business logic inside the application.
There are various form elements available like text fields, textarea
fields, drop-down menus, radio buttons, checkboxes, etc.
The <form> Element
The HTML <form> tag is used to create an HTML form and it has
following syntax −
<form>
.
form elements
.
</form>
If the name attribute is omitted, the value of the input field will not be sent at
all.
Form Attributes
Usually, the form data is sent to a file on the server when the user
clicks on the submit button.
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
Tip: If the action attribute is omitted, the action is set to the current page.
Form Attributes
The Target Attribute
The target attribute specifies where to display the response that is received after
submitting the form.
The target attribute can have one of the following values:
This example uses the POST method when submitting the form data:
<form action="/action_page.php" method=“post">
Form Attributes
The Method Attribute
Notes on GET:
Appends the form data to the URL, in name/value pairs
NEVER use GET to send sensitive data! (the submitted form data is visible in the URL!)
The length of a URL is limited (2048 characters)
Useful for form submissions where a user wants to bookmark the result
GET is good for non-secure data, like query strings in Google
Notes on POST:
Appends the form data inside the body of the HTTP request (the submitted form data is
not shown in the URL)
POST has no size limitations, and can be used to send large amounts of data.
Form submissions with POST cannot be bookmarked
Tip: Always use POST if the form data
contains sensitive or personal information!
Form Attributes
The Autocomplete Attribute
The autocomplete attribute specifies whether a form should have autocomplete on or
off.
When autocomplete is on, the browser automatically complete values based on values
that the user has entered before.
https://www.w3schools.com/html/html_forms_attributes.asp
HTML Form Elements
The HTML <form> Elements
The HTML <form> element can contain one or more of the following form elements:.
<input>
<label>
<select>
<textarea>
<button>
<fieldset>
<legend>
<datalist>
<output>
<option>
<optgroup>
The <select> Element
Visible Values:
Use the multiple attribute to allow the user to select more than one value:
The rows attribute specifies the visible number of lines in a text area.
https://learn.shayhowe.com/html-css/getting-to-know-css/
https://www.w3schools.com/css/css_selectors.asp
<b>THE END</b>
THE END