Only POST array when key matters

This is strange to me. But after upgrading to php 5.6.1, I noticed that POST arrays are not populating properly. With this code:

<form action="" method="POST">
<input type="text" name="username" />
<input type="submit" value="click">
</form>

If I just click submit, I get an empty array. BUT, if I fill in the text input (i.e. John Doe). The array is displayed as it should. I checked the raw POST data:

$raw_post = file_get_contents('php://input');

and it is sent (even when it is empty), but it just does not appear in the array. I.e:

Array ( )

I'm not even sure if this is due to the update, but I just noticed it after dodging.

+4
source share
1 answer

You need to identify value=""in each input

<form action="" method="POST">
    <input type="text" name="username" value=""/>
    <input type="submit" value="click">
    </form>
0
source

All Articles