Php post parameter retrieval-php Tutorial

Source: Internet
Author: User
For PHP's first attempt to obtain the POST parameter, I would like to ask, my front-end html, the data submitted with get, the address bar is like this:
.../... & A = good_1 & B = 200 & a = good_2 & B = 300 & a = good_4 & B = 400

Use $ _ GET to GET the parameter value in the PHP file, and use foreach ($ _ REQUEST as $ key => $ value)
But only the last one can be obtained, that is, a = good_4 & B = 400. The other two cannot be obtained. how can this problem be solved?


Reply to discussion (solution)

Your key already exists.

Because the url parameter string violates the php convention (the input variable with the same name must be in the array format ),
You can parse it from $ _ SERVER ['query _ string ']

This is not a duplicate key.
.... /.. & A [] = good_1 & B [] = 200 & a [] = good_2 & B [] = 300 & a [] = good_4 & B [] = 400
In this way, the value can be obtained.

Your key already exists.

Your parameter fields except a and B are already repeated.

The parameter already exists.

If the parameter names are repeated, they will be overwritten.

& A = good_1 & B = 200 & a = good_2 & B = 300 & a = good_4 & B = 400
The parameters are repeated and will be overwritten. You can use an array or change the parameter name.
For example:
& A [] = good_1 & B [] = 200 & a [] = good_2 & B [] = 300 & a [] = good_4 & B [] = 400

Array(    [0] => good_1    [1] => good_2    [2] => good_4)Array(    [0] => 200    [1] => 300    [2] => 400)

Because the url parameter string violates the php convention (the input variable with the same name must be in the array format ),
You can parse it from $ _ SERVER ['query _ string ']


The moderator is so fine as he knows php ???

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.