Is there a way in PHP to capture ALL the information passed using the POST method

Some time ago, I asked a question about using the same input / hidden name several times on the page and received an answer that did not work, as he suggested that I use it to put brackets after the field name, like partno[].

I cannot use this in my form, since the cart is sent only to recognize certain field names, such as: partno, item, price, qty, etc. (I can not use partno[], item[], etc.). Therefore, I really should be able to get all the values ​​for each name of the same field used several times. When I use the method GET, it will display all the values ​​for each field name used in the address bar. You can try this and submit the form. Look at the URL in the address bar.

My new question is: is there a way in PHP to capture all the information passed using the method POST? (for example, what is shown in the address bar in the above example, but using POST, but not GET). I can make it out if I can figure out how to capture it.

Thanks Kelly

+5
source share
5 answers

You just use $_POSTinstead $_GET.

So, if you used get as follows:

?something=somevalue

And they caught it with the help $_GET['something'], now you would use it $_POST['something'].

+2
source

You can get unoccupied data directly from the input stream:

file_get_contents('php://input');

So, if you have something like this:

<input name="type" value="val1">
<input name="type" value="val2">
<input name="type" value="val3">

You will get a line like this:

type=val1&type=val2&type=val3

" ".

http://php.net/manual/en/wrappers.php.php

php://input - , , . POST php:// $HTTP_RAW_POST_DATA, php.ini. , , $HTTP_RAW_POST_DATA , always_populate_raw_post_data. php:// ENCTYPE = "/-".

+2

POST PHP - , , .

foreach($_POST as $k => $v) {
   echo($k . ': '. $v . '<br>');
}
+1

, $_POST , var_dump ($ _ POST), echo print_r ($ _ POST). , , , partno [].

0

There is no way to enter POST 2 with the same name as the string. You must change the recycle bin to convert the array to a string.

If you use GET, you can check the parse_url () function .

-1
source

All Articles