2

Submitting this form:

<?php
var_dump($_POST);
var_dump(file_get_contents("php://input"));
?>
<form method="post" enctype="multipart/form-data">
<input name="test" value="0">
<input name="test[0].0" value="00">
<input name="test[0].1" value="01">
<input name="test[1].0" value="10">
<input name="test[1].1" value="11">
<input type="submit">
</form>

Results in:

array(1) {
  ["test"]=>
  array(2) {
    [0]=>
    string(2) "01"
    [1]=>
    string(2) "11"
  }
}
string(0) ""

How do I get the missing input values in php7 without changing the html code?

YasserKaddour
  • 880
  • 11
  • 23
guest
  • 21
  • 1
  • 2
  • 6
    PHP 5 behaves the same. What do you expect? `test[0].0` is not a valid variable name. – Gerald Schneider Feb 14 '17 at 14:21
  • 1
    Without "multipart/form-data", I could parse it manually from "php://input" in php5 also from $HTTP_RAW_POST_DATA. The POST data in this example is "test=0&test[0].0=00&test[0].1=01&test[1].0=10&test[1].1=11" which is submitted by the browser. –  Feb 14 '17 at 14:41
  • Please check the linked question and let me know if whether my solution works for you in PHP/7. – Álvaro González Feb 14 '17 at 16:30
  • The HTML form is generated from a webserver I cannot change. Changing the content type in apache config is not possible, putting it in .htaccess does not seem to work. – guest Feb 14 '17 at 17:04
  • @guest Did you try disabling `enable_post_data_reading`? – Álvaro González Feb 15 '17 at 09:37
  • @ÁlvaroGonzález Putting "php_value enable_post_data_reading 0" in .htaccess works, I did have to change some code. – guest Feb 20 '17 at 11:51

1 Answers1

3

$HTTP_RAW_POST_DATA was deprecated in PHP 5.6 and removed completely in PHP 7.0.

You have to change your html code.

<input name="test[0][0]" value="00">
<input name="test[0][1]" value="01">
<input name="test[1][0]" value="10">
<input name="test[1][1]" value="11">

And then get them by

$_POST['test'][0][0]
Paul T. Rawkeen
  • 3,994
  • 3
  • 35
  • 51
John
  • 158
  • 1
  • 5