Get the HTML form (form) data _php Tutorial with PHP's hyper-variable $_get

Source: Internet
Author: User
$_get is one of the super variables in PHP.

When the method of an HTML form (HTML form) is GET, $_get is used to get the data for the HTML form.

Gets the HTML form (HTML form) text input box (input type= "text") data
The following is an HTML file that contains an HTML form (HTML form) that is used primarily to allow users to enter the user's name.
Copy CodeThe code is as follows:

<title>blablar.com HTML Form Method Get Example</title>





The HTML display interface is as follows:

When you enter the name in the form text box of the HTML file, such as "Jacky", then click OK button, the mouse will jump to get.php, in get.php will show as.

The source code for get.php is as follows:
Copy the Code code as follows:

blablar.com PHP $_get Example

You are .



Takes the name value of the form control to get the data for the form control.

For example, "username" is the name value of the text input box for the form control.
Copy the Code code as follows:


Use $_get["username" to get the data for the text input box.
Copy the Code code as follows:
echo $_get["username"]
?>

Get HTML form (HTML form) radio box (input type= "Radio") data
You can get the value of the table-only marquee by taking the name value of the form's single box.

The following is an HTML file containing the form box, with the following code:
Copy the Code code as follows:

Blablar.com





This is illustrated below:

In the HTML file, choose a random item, such as select "Orange", and then click the button OK, the browser will jump to radio.php, in the radio.php display result is "orange". The source code for radio.php is as follows:
Copy the Code code as follows:

Blablar.com





The fruit in $_get["fruit" is the name value of the form's marquee.

Get HTML form (HTML form) check box (input type= "checkbox") data
The user can select multiple values through the HTML Form check box, so the $_get gets more than one value, which is the array.

Note that when you write the name value of the HTML Form check box, the name value is added to the last [].

In the example below, name= "fruit[]":
Copy the Code code as follows:

Blablar.com





The HTML file displays the results

If you select orange and mango and click the OK button, the browser jumps to checkbox.php and displays the results.

The source code for checkbox.php is as follows:
Copy the Code code as follows:

Blablar.com

echo count ($_get["fruit"]), "
";
foreach ($_get["fruit"] as $value)
{echo $value, "
";
}
?>



Use the Count function to get the number of elements of the array $_get["fruit", if the user has selected 2 items, the result is 2. Then use the Foreach loop to output the value of each element of the $_get["fruit", which is the value of the item selected by the user, orange and mango.

In the next section we describe the use of PHP super variable $_post to get the data of an HTML form (HTML form).

http://www.bkjia.com/PHPjc/323381.html www.bkjia.com true http://www.bkjia.com/PHPjc/323381.html techarticle $_get is one of the super variables in PHP. When the method of an HTML form (HTML form) is GET, $_get is used to get the data for the HTML form. Get HTML form (HTML form) text input box ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.