Home Web Front-end HTML Tutorial How to use the method attribute of the form tag in HTML? Here is an introduction to the usage of the method attribute

How to use the method attribute of the form tag in HTML? Here is an introduction to the usage of the method attribute

Aug 28, 2018 pm 06:02 PM
form html method

This article mainly introduces the definition and usage explanation of the method attribute of the form tag in HTML, and gives a detailed explanation. There are two common questions and answers and examples of the method attribute later. Let us now Let’s take a look together

First of all, let’s take a look at the meaning of the method attribute of the form tag in HTML?

The method attribute specifies how to send form data (the form data is sent to the page specified by the action attribute).

Form data can be sent as URL variables (method="get") or HTTP post (method="post").

Let’s take a look at the explanation of the use of the method attribute in the form tag:

The browser uses the method attribute setting method to transmit the data in the form to the server for processing. There are two methods: POST method and GET method.

If the POST method is used, the browser will follow the following two steps to send data. First, the browser will establish contact with the form processing server specified in the action attribute. Once the connection is established, the browser will send the data to the server in a segmented transmission method.

On the server side, once the POST style application starts executing, the parameters should be read from a flag location. Once the parameters are read, these parameters must be modified before the application can use these form values. to decode. User-specific servers explicitly specify how applications should accept these parameters.

Another situation is to use the GET method. In this case, the browser will establish a connection with the form processing server and then send all the form data directly in one transmission step: the browser will attach the data directly to the form. after the action URL. Use a question mark to separate the two.

General browsers can transmit form information through any of the above methods, while some servers only accept data provided by one of the methods. You can specify the method (method) attribute of the

tag that the form processing server should use to process data, whether POST or GET.

Let’s look at two common questions and answers now:

1. In addition to post, what other values ​​can be attached to get?

Answer: Only post and get are possible

post: The official explanation is to transmit the data to the server through the post session. The actual thing is to submit the data.

get: Add the data in the form to the end of the URL pointed to by the action in the form of variable=value, and use "?" to connect the two, and use "&" to connect each variable; generally Used to get data from the server.

2. What is the default value of the method attribute?

Answer: The default is get, so generally we have to specify it as post

Give an example of the method attribute of the from tag:

In the following example, the form data will be appended to the URL through the method attribute:

<form action="form_action.asp" method="get">
  <p>这是第一个名字: <input type="text" name="fname" /></p>
  <p>这是第二个名字: <input type="text" name="lname" /></p>
  <input type="submit" value="Submit" />
</form>
Copy after login

The example result is as shown:

How to use the method attribute of the form tag in HTML? Here is an introduction to the usage of the method attribute

This article ends here. I have also seen the results. You should be familiar with the method attribute. If you have any questions, you can ask below

[Editor’s Recommendation]

How to write a relative path for the base tag in HTML? (Introduction to use included)

#What is the role of the HTML meta tag? Introduction to how to use html meta tag

The above is the detailed content of How to use the method attribute of the form tag in HTML? Here is an introduction to the usage of the method attribute. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles