Use PHP's super variable $_POST to obtain HTML Form data_PHP tutorial
WBOYOriginal
2016-07-21 15:29:301032browse
When the method of the HTML Form is get, $_GET is used to obtain the data of the 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 in HTML Form, please refer to the difference between get and post in HTML Form.
Get HTML Form text input box (input type="text") data The following is an HTML file. This HTML contains an HTML Form, which is mainly used to allow users to enter user names. .
Copy code The code is as follows:
When you enter your name in the text box input box of this HTML Form , such as "Jacky", and then click the ok button with the mouse, it will jump to post.php, and the output result displayed is You are Jacky. The source code of post.php is as follows:
Copy code The code is as follows:
You are .
Get form control The name value of the form control can be used to obtain the data of the form control.
For example, "username" is the name value of the form control text input box,
Use $_POST[" username"] can obtain the data of the text input box.
Get HTML Form (HTML Form) radio button (input type="radio") data Get form radio button The name value of the box can be used to obtain the value of the form radio button.
The following is an HTML file containing form radio buttons. The code is as follows:
Copy the code The code is as follows:
In the HTML file, select any item, for example, select "Orange", and then click the ok button, 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:
Copy code The code is as follows:
$_POST["fruit" The fruit in ] is the name value of the form radio button.
Get HTML Form checkbox (input type="checkbox") data Users can select multiple values through HTML Form checkbox, so $_POST gets more than one value, is an array.
When writing the name value of the HTML Form check box, please note that [ ] must be added at the end of the name value.