Missing PHP $_POST Values from php://input
Despite receiving form data through a POST request, certain values fail to appear in the PHP $_POST array. Debugging reveals the presence of these values in the raw request string retrieved via php://input.
Cause:
PHP alters field names containing specific characters (spaces, dots, open square brackets, etc.) to comply with the deprecated register_globals.
Solution:
<code class="php">function getRealPOST() { $pairs = explode("&", file_get_contents("php://input")); $vars = array(); foreach ($pairs as $pair) { $nv = explode("=", $pair); $name = urldecode($nv[0]); $value = urldecode($nv[1]); $vars[$name] = $value; } return $vars; }</code>
The above is the detailed content of Why are My $_POST Values Missing from My PHP Script?. For more information, please follow other related articles on the PHP Chinese website!