Bug #70028 [Fbk->Opn]: $_POST data being automatically filtered.

From: Date: Wed, 08 Jul 2015 21:11:03 +0000
Subject: Bug #70028 [Fbk->Opn]: $_POST data being automatically filtered.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194229@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70028&edit=1 ID: 70028 User updated by: treboralmasy1 at gmail dot com Reported by: treboralmasy1 at gmail dot com Summary: $_POST data being automatically filtered. -Status: Feedback +Status: Open Type: Bug Package: *General Issues PHP Version: 5.6.10 Block user comment: N Private report: N New Comment: The SAPI used is CGI PHP. An example of the problem can be found here: http://myservicecalls.com/postTest.php Code in link: <?php error_reporting(E_ALL); $raw_post = file_get_contents('php://input'); echo 'php://input: '.$raw_post; echo '<br/>'; print_r($_POST); echo '<br/>'; $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == 'cgi') { echo "You are using CGI PHP\n"; } else { echo "You are not using CGI PHP\n"; } ?> <form action="postTest.php" method="POST"> <input type="text" name="username" /> <input type="submit" value="click"> </form> Previous Comments: ------------------------------------------------------------------------ [2015-07-08 19:22:43] cmb@php.net 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? ------------------------------------------------------------------------ [2015-07-08 17:17:40] 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> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70028&edit=1

« previous php.bugs (#194229) next »