Curriculum
Course: HTML Basic
Login

Curriculum

HTML Basic

HTML Introduction

0/1

HTML Editors

0/1

HTML Attributes

0/1

HTML Paragraphs

0/1

HTML Formatting

0/1

HTML Comments

0/1

HTML Favicon

0/1

HTML Page Title

0/1

HTML Iframes

0/1

HTML Java Script

0/1

HTML File Paths

0/1

HTML Symbols

0/1
Text lesson

The formmethod Attribute

The “formmethod” attribute of the input element specifies the HTTP method for transmitting form-data to the action URL.

Crucially, this attribute takes precedence over the “method” attribute of the <form> element.

The “formmethod” attribute is compatible with the following input types: submit and image.

Form data can be dispatched either as URL variables (method=”get”) or as an HTTP post transaction (method=”post”).

Points regarding the “get” method:

  • This approach attaches the form-data to the URL as name/value pairs,
  • a method often employed when users wish to bookmark the outcome of their form submission.
  • It’s important to acknowledge that there’s a limit to the amount of data that can be accommodated in a URL (which varies across browsers), hence, complete transfer of all form-data isn’t guaranteed.
  • Under no circumstances should the “get” method be used to transmit sensitive information! Doing so would expose passwords or other confidential data in the browser’s address bar.

Points regarding the “post” method:

  • This approach transmits form-data via an HTTP post transaction.
  • Unlike “get” submissions, form submissions with the “post” method cannot be bookmarked.
  • The “post” method is notably more robust and secure than “get”. Additionally, it doesn’t impose size limitations.

Example

A form featuring two submit buttons: one transmits the form-data using the “get” method, while the other transmits it using the “post” method.

<form action=”/action_page.php” method=”get”>
  <label for=”fname”>First name:</label>
  <input type=”text” id=”fname” name=”fname”><br><br>
  <label for=”lname”>Last name:</label>
  <input type=”text” id=”lname” name=”lname”><br><br>
  <input type=”submit” value=”Submit using GET”>
  <input type=”submit” formmethod=”post” value=”Submit using POST”>
</form>