|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-07-08 17:17 UTC] treboralmasy1 at gmail dot com
Description:
------------
When a form is submitted with an empty value $_POST does not add an empty key. Instead it automatically filters it. If data is entered $_POST behaves like normal (populates key and value).
Ie: when no code is entered:
file_get_contents('php://input'):
username=
$_POST:
array()
when username IS entered:
file_get_contents('php://input'):
username=test
$_POST:
array( username=>test)
Test script:
---------------
<form action="" method="POST">
<input type="text" name="username" />
<input type="submit" value="click">
</form>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 10:00:01 2025 UTC |
I'm not able to reproduce the described behavior with the following self contained test script (PHP 5.6.10, built-in webserver): <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { var_dump($_POST); var_dump(file_get_contents('php://input')); } ?> <form action="<?=$_SERVER['PHP_SELF']?>" method="POST"> <input type="text" name="username"> <input type="submit" value="click"> </form> Which SAPI do you use?