Using PHP's super variable $_GET to obtain HTML form (Form) data_PHP tutorial
WBOY
Release: 2016-07-21 15:29:28
Original
876 people have browsed it
$_GET is one of PHP’s super variables.
When the method of HTML Form is get, $_GET is used to obtain the data of 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 the user's name.
Copy code The code is as follows:
Blablar.com HTML Form Method Get Example
The HTML display interface is as follows:
When you enter your name in the form text box input box of this HTML file, such as "Jacky", and then click the ok button, it will jump to get.php, and the following picture will be displayed in get.php.
The source code of get.php is as follows:
Copy the code The code is as follows:
Blablar.com PHP $_GET Example
You are
Get the name value of the form control to get the data of the form control.
For example, "username" is the name value of the form control text input box,
Copy the code The code is as follows:
Use $_GET["username"] to get the data of the text input box.
Copy code The code is as follows:
echo $_GET["username"] ?>
Get the HTML Form radio button (input type="radio") data Get the name value of the form radio button to get the form radio button value.
The following is an HTML file containing form radio buttons. The code is as follows:
Copy the code The code is as follows:
Blablar.com
The icon is as follows:
In the HTML file, select an item at random, for example, select "Orange", and then click the ok button. The browser will jump to radio.php, and the displayed result in radio.php is "Orange". The source code of radio.php is as follows:
Copy the code The code is as follows:
Blablar.com
The fruit in $_GET["fruit"] 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 $_GET 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.
The following example, name="fruit[ ]":
Copy code The code is as follows:
Blablar.com
body>
The HTML file displays the results as shown below:
If you select Orange and Mango and click the OK button, the browser will jump to checkbox.php and display the result as shown in the figure.
Use the count function to get the number of elements in the array $_GET["fruit"]. If the user selects 2 items, The result obtained is 2. Then use a foreach loop to output the value of each element of $_GET["fruit"], which is the value of the item selected by the user, Orange and Mango.
In the next chapter we will talk about using the PHP super variable $_POST to obtain the data of the HTML Form (HTML Form).
http://www.bkjia.com/PHPjc/323381.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323381.htmlTechArticle$_GET is one of the super variables of PHP. When the method of the HTML Form is get, $_GET is used to obtain the data of the HTML Form. Get HTML Form text input box...
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