php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #78584 Could you please populate $_FORMDATA?
Submitted: 2019-09-22 12:02 UTC Modified: 2019-09-22 12:09 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: 6562680 at gmail dot com Assigned:
Status: Suspended Package: *General Issues
PHP Version: 7.2.23RC1 OS: Win10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: 6562680 at gmail dot com
New email:
PHP Version: OS:

 

 [2019-09-22 12:02 UTC] 6562680 at gmail dot com
Description:
------------
When PHP parses url with parse_str() to populate $_POST/$_FILES on multipart/form-data,PHP merges same keys into one value, its known behavior.

I tried to fill form fields after redirect from POST to GET with validation error. When merged - it's not possible. Would be great to have $_FORMDATA that should looks like this (opinion): 

[
  ['hello[name][]', 123],
  ['hello[name][]', 123],
  ['hello[]', 123],
  ['hello[]', 123],
  ['hello', 123],
]

because $_POST will looks like [ 'hello' => 123 ]

Problem happened when we work with multifields (button '+ add field') or multiselects - where we should set "selected" for its options

Test script:
---------------
// get.php

<form method="POST" type="multipart/form-data">
  <select multiple="multiple" name="hello[name][]">
    <option value="123">123</option>
  </select>
  <input type="text" name="hello[name][]" value="123" />
  <input type="text" name="hello[name][]" value="123" />
  <input type="text" name="hello[]" value="123" />
  <input type="text" name="hello[]" value="123" />
  <input type="text" name="hello" value="123" />
  <button type="submit">Send</button>
</form>

// post.php
var_dump($_POST);

Expected result:
----------------
var_dump($_POST);
[ 'hello' => '123' ]

var_dump($_FORMDATA);
[
  ['hello[name][]', 123], // select(multiple)
  ['hello[name][]', 123], // input[]
  ['hello[name][]', 123], // input[]
  ['hello[]', 123], // input[]
  ['hello[]', 123], // input[]
  ['hello', 123], // input
]


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-22 12:09 UTC] requinix@php.net
-Status: Open +Status: Suspended -Package: *Web Server problem +Package: *General Issues
 [2019-09-22 12:09 UTC] requinix@php.net
A feature like this requires going through the RFC process. https://wiki.php.net/rfc/howto
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 05 16:01:33 2025 UTC