English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
This article introduces the usage of the HTML form method attribute, online examples demonstrating how to use the HTML form method attribute, browser compatibility, syntax definition, and detailed information about its attribute values.
Submit the form using the "get" method:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML <form> get method usage-Basic Tutorial(oldtoolbag.com)</title> </head> <body> <form action="action_page.php" method="get"> First name: <input type="text" name="fname"><br> Last name: <input type="text" name="lname"><br> <input type="submit" value="Submit"> </form> </body> </html>Test to see ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the method attribute.
The method attribute specifies how form data is sent (form-data) (the form data will be sent to the page specified in the action attribute).
Form data can be sent as URL variables (method="get") or as part of an HTTP POST transaction (method="post").
Comments on GET:
The form data is sent with the name/The value pair is appended to the URL
The length of the URL is limited (about 3000 characters)
Never use GET to send sensitive data! (Visible in the URL)
Very useful for form submissions that users want to add to bookmarks
GET is more suitable for non-sensitive data, such as query strings in Google
Notes on POST:
Attach form data to the body of the HTTP request (data is not displayed in the URL)
No length limit
Forms submitted via POST cannot be added to bookmarks
None.
<form method="get|post">
Value | Description |
---|---|
get | Default. Attach form data (form-data) with the name/Pairs of values appended to the URL: URL?name=value&name=value. |
post | Send form data in the form of an HTTP POST transaction (form-data). |
Submit the form using the "post" method
Send form data using the "post" method.