Php - Form - HTTP Request/Response

Card Puncher Data Processing


Form and HTTP Fetch in php


Php does not support multiple form control with the same name.

Even if it receive several values for the same name via a valid multipart-form-data, it will pass only the last value to the _POST global variable.

To resolve this issue at the php sauce, you need to:

  • add bracket to the name value (ie my-input-name[])
  • or use unique name value

Although HTML allows multiple values regardless of name, PHP doesn't, and this behaviour is well established. Closing won't fix.



The _POST 1) global variable is build by php when the body of the request has:

For other format, you need to build the _POST global variable yourself from the body available via the input stream.

Example with content-type set to Json

if ($_SERVER["CONTENT_TYPE"] === "application/json") {
    $_POST = json_decode(file_get_contents('php://input'), true);

Documentation / Reference

Share this page:
Follow us:
Task Runner