The previous section describes how to use the PHP super variable $ _ GET to obtain HTML Form data. This section describes how to use the PHP super variable $ _ POST to obtain HTMLForm data.
The previous section describes how to use the PHP super variable $ _ GET to obtain HTML Form data. This section describes how to use the PHP super variable $ _ POST to obtain HTML Form data.
When the method of HTML Form is get, $ _ GET is used to obtain the data of HTML Form.
When the method of HTML Form is post, $ _ POST is used to obtain the data of HTML Form.
For the difference between get and post of HTML Form, see the difference between get and post of HTML Form.
Obtain the data in the HTML Form text input box (input type = "text ").
The following is an HTML file. This HTML contains an HTML Form, which is mainly used for users to input user names.
When You enter a name in the text box of the HTML Form, such as "Jacky", and then click OK, the page will jump to post. php. The output result is You are Jacky .. The source code of post. php is as follows:
Obtain the data of the Form Control by taking the name value of the Form Control.
For example, "username" is the name value of the text input box of the Form Control,
You can use $ _ POST ["username"] to obtain the data in the text input box.
Obtain HTML Form (HTML Form) single dataset (input type = "radio") data
You can obtain the value of the single-sheet signature by taking the name value of the single-sheet signature.
The following is an HTML file containing a single sheet.
In this HTML file, select either item, for example, "Orange", and click "OK". the browser will jump to radiopost. php, and the output result of radiopost. php is Orange. The source code of radiopost. php is as follows:
In $ _ POST ["fruit"], fruit is the name value of the form ticket.
Obtain the data of the HTML Form check box (input type = "checkbox ")
You can select multiple values through the HTML Form check box. Therefore, $ _ POST produces more than one value, which is an array.
When writing the name value of the HTML Form check box, note that [] must be added at the end of the name value.
For example, name = "fruit []":
The source code of checkboxpost. php is as follows:
The Code is as follows: