php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52548 multiple $_POST array values not being assigned correctly
Submitted: 2010-08-06 01:48 UTC Modified: 2010-08-06 02:05 UTC
From: qrstuv+php at gmail dot com Assigned:
Status: Not a bug Package: HTTP related
PHP Version: Irrelevant OS: Ubuntu 10.04
Private report: No CVE-ID: None
 [2010-08-06 01:48 UTC] qrstuv+php at gmail dot com
Description:
------------
The value of a $_POST array item is not being assigned properly

Test script:
---------------
<form method="post">
<input type="submit" name="step4[edit][change]" value="Submit and continue">
<input type="submit" name="step4[edit]" value="Continue without changes">
</form>

<?
//After form submission
var_dump($_POST['step4']['edit']['change']);
?>

Expected result:
----------------
//When "Continue without changes" is pressed, expected value:
NULL

Actual result:
--------------
//When "Continue without changes" is pressed...

//Actual value:
string(1) "C"

//The "C" is taken from the first character of the value of $_POST['step4']
['edit']

//A var_dump of $_POST['step4']['edit'] returns the value as expected as does a 
var_dump of $_POST['step4']['edit']['change'] when that is actually pressed.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-06 02:05 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2010-08-06 02:05 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

In your example $_POST['step4']['edit'] will be set to "Continue without changes", the offset ['change'] will be used as string index, 'change' is being casted to an integer value, 0, so the first character is returned.
 [2010-08-06 02:11 UTC] qrstuv+php at gmail dot com
Ah, I understand. Thank you for your prompt response. Sorry for the bogus report.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC