Fang Fang - 25 days ago 14
PHP Question

GET works but POST doesn't

I have a simple HTML form:

<form class="form-signin" action="formHandler.php" method="post">
<h2 class="form-signin-heading">Login</h2>
</br>
</br>
<label for="inputUsername" class="sr-only">Benutzername</label>
<input type="inputUsername" name="inputUsername" id="inputUsername" class="form-control" placeholder="Username" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" name="inputPassword" id="inputPassword" class="form-control" placeholder="Password" required>
</br>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
<button class="btn btn-lg btn-primary btn-block" type="clear">Clear</button>
</form>


which I send to the following PHP script:

var_dump($_POST);
var_dump($_GET);


When I use GET, my variables get passed correctly. However, when I use post (as in the example) var_dump($_POST) returns an empty array.

Answer

After extensive searching, I found out that the issue is rooted in PHPStorm's local environment. The POST request works fine when the site is deployed to a local Apache environment or when uploaded to a website.

The problem is documented on IntelliJ website:

POST Problem with PHPStorm 10.02 and onwards

Jetbrains issuetracker with the issue in question:

https://youtrack.jetbrains.com/issue/WI-31257

Comments