9

$_POST seems that does not work. I've installed PhpStorm 10.0.3, and using the WAMP server default php interpreter.

in the index.php:

<form method='post' action='a.php'>
    <input type='text' name='user_f'>
    <input type='submit' name='send' value='Send'>
</form>

In the a.php:

var_dump($GLOBALS);

when I type "asdf" in the form:

array (size=9)
      'HTTP_RAW_POST_DATA' => string 'user_f=asdf&send=Send' (length=22)
      '_GET' => 
        array (size=0)
          empty
      '_POST' => 
        array (size=0)
          empty
      '_COOKIE' => 
        array (size=0)
          empty
      '_FILES' => 
        array (size=0)
          empty
      '_ENV' => 
        array (size=0)
          empty
      '_REQUEST' => 
        array (size=0)

$_GET works good, but seems like the interpreter don´t fill the $_POST variable.

php.version: 5.4.12 (same problem using 5.6.18 and 7 interpreters from http://php.net/downloads.php )

php.ini file for this version:(default from wamp)

Other ports like (3306) for MySQL works good in the PhpStorm. (Connection with phpmyadmin is ok)

Xdebug port : 9000 PhpStorm built-in server port: 63342

Everything works good if i build from Netbeans IDE in the default localhost:8000

Same problem in my laptop.

fedorqui
  • 275,237
  • 103
  • 548
  • 598
espumita
  • 157
  • 1
  • 6
  • 13
    Use Apache from WAMP (or any other proper web server) to serve your web requests. Right now you are using PhpStorm's own built-in simple web server which ATM has issues with handling POST requests. – LazyOne Feb 09 '16 at 10:56
  • 3
    Actual (main) ticket on JB Issue Tracker: https://youtrack.jetbrains.com/issue/WEB-17317 . In addition to using proper web server (Apache/nginx/IIS/etc) you can also use PHP's own web server (can be launched using "PHP Built-in Web Server" type of Run/Debug Configuration) – LazyOne Feb 09 '16 at 11:21
  • Built-in Sever finally works !!! thank you!! – espumita Feb 10 '16 at 17:26
  • Can also confirm this issue for PhpStorm for macSierra, issue only occurs within the IDE for post requests. Placing my php post request in my xampp's folder works fine. –  Feb 16 '17 at 00:27

4 Answers4

2

The new PhpStorm 2017.2.2 EAP build (172.3968.23) has solved this problem.

Bug WEB-17317 502 Bad Gateway error from the server when post data.

You can download it here.

Complete Release notes link=>confluence.jetbrains.com/display/PhpStorm/PhpStorm+EAP+172.3968.23+Release+Notes

jerry
  • 21
  • 4
0

Paste this workaround in your page's initialization to use $_POST as normal:

<?php
//required when using PhpStorm's built-in webserver
//which always makes $_POST empty
//and must have .ini setting always_populate_raw_post_data = -1
//but will NOT work with enctype="multipart/form-data"
$raw_str = file_get_contents('php://input'); //eg. name1=val&name2=val
if($raw_str) {
    foreach (explode('&', $raw_str) as $pair) {
        $keyvalue = explode("=", $pair);
        $key = urldecode($keyvalue[0]);
        $value = urldecode($keyvalue[1]);
        $_POST[$key] = $value;
    }
}
?>
Michelle Norris
  • 568
  • 7
  • 14
0

It doesn't matter with PHPSTORM, HTTP_RAW_POST_DATA can store unrecognized data from request, have a try , content-type:application/x-www-form-urlencoded add to Http headers;

lele
  • 1
  • 1
-2

Try setting the enctype of the form, without it the $_POST array might not be populated as PHP only receives a string of fields without knowing what to do with it:

<form method='post' action='a.php' enctype="multipart/form-data">
    <input type='text' name='user_f'>
    <input type='submit' name='send' value='Send'>
</form>
bardiir
  • 14,556
  • 9
  • 41
  • 66