In php, there are several forms to submit data. one is post and get. next I will introduce php beginners in detail how to use get and post to receive data submitted by forms, friends who need to know
In php, there are several forms to submit data. one is post and get. next I will introduce php beginners in detail how to use get and post to receive data submitted by forms, for more information, see.
PHP $ _ GET and $ _ POST variables are used to obtain information in the form. for example, the user input information PHP4.1 (as if) is canceled and directly receives the variable, instead, use $ _ GET ['variable name'] to receive the variables passed from the link and use $ _ POST ['variable name'] to receive the variables submitted from the form. there are also $ _ FILES [], $ _ SERVER [], etc.
The following is an HTML file. This HTML contains an HTML Form, which is mainly used for users to input user names.
The instance code is as follows:
-
The HTML display interface is as follows:
When you enter a name in the form text box of this HTML file, such as "Jacky", and then click the OK button, the page will jump to get. php, as shown in get. php.
The source code of get. php is as follows:
The instance code is as follows:
- .
Take the name value of the form control to obtain the data of the form control. for example, "username" is the name value of the text input box of the form control.
The instance code is as follows:
-
You can use $ _ GET ["username"] to obtain the data in the text input box.
The instance code is as follows:
-
Obtain the data of an HTML Form (HTML Form) single Partition (input type = "radio"), obtain the name value of a single partition of the Form, and obtain the value of a single partition of the Form. $ _ POST: obtain HTML form submission data.
The following is an HTML file. This HTML contains an HTML Form, which is mainly used for users to input user names.
The instance code is as follows:
-
When you enter a name in the text box of the HTML Form, such as "Jacky", and then click the OK button, the page will jump to post. php, the output result is You are Jacky .. post. the source code of php is as follows:
The instance code is as follows:
- You are .
Take the name value of the form control to obtain the data of the form control. for example, "username" is the name value of the text input box of the form control,
The instance code is as follows:
-
You can use $ _ POST ["username"] to obtain the data in the text input box.
The instance code is as follows:
-
$ _ REQUEST variable
The PHP $ _ REQUEST variable contains $ _ GET, $ _ POST, and $ _ COOKIE content, the PHP $ _ REQUEST variable can be used to obtain the form data sent through the "GET" and "POST" methods.
The instance code is as follows:
- Welcome .
- You are Years old