PHP $ _ get html Form (Form) or url data

Source: Internet
Author: User
Tags html form

1. $ _ GET is used to obtain data in the form of get in the table method.
2. $ _ GET url. php? I = 12 data,
The above is the data we often use get to obtain values,

Instance 1: Get form data

The code is as follows: Copy code

<Form action = "get. php" method = "get">
Name: <input type = "text" name = "username"/>
<Input type = "submit" value = "OK"/>
</Form>

Get. php

Assume that I entered www.111cn.net

The code is as follows: Copy code

You are <? Php echo $ _ GET ["username"]?>.


The output result is

The code is as follows: Copy code

You are www.111cn.net

What is the url style when we click to submit?

The code is as follows: Copy code

Get. php? Username = www.111cn.net

This form is the second method we are talking about to obtain data. Next we will look at using a for reference.

/A. php? Value = my

A. php

The code is as follows: Copy code

The value of value is <? Php echo $ _ GET ["value"];?>. <Br/>

The output result is

The code is as follows: Copy code

The value of value is my.


This seems to be no different from form's method = get. Haha, the article is here.


There is also a way to get, that is, the form of direct $ _ GET, and view the instance.

The code is as follows: Copy code

<Form action = "checkbox. php" method = "get">
<Input type = "checkbox" name = "fruit []" value = "Apple"> Apple </input> <br/>
<Input type = "checkbox" name = "fruit []" value = "Orange"> Orange </input> <br/>
<Input type = "checkbox" name = "fruit []" value = "Mango"> Mango </input> <br/>
<Input type = "submit" value = "OK">


Checkbox. Php file code

The code is as follows: Copy code

<? Phpecho count ($ _ GET ["fruit"]), "<br/> ";
Foreach ($ _ GET ["fruit"] as $ value)
{Echo $ value, "<br/> ";
}?>

The output result is


If you choose Orange and Mango


Note that $ _ GET is not suitable for obtaining a large amount of data. The length value cannot exceed 100 characters.

Original site Original tutorial reprint must be noted Source: http://www.111cn.nethttp: // www.111cn.net/phper/php.html

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.