I am having some problems with the POST method for form submission in a localhost. I created a very simple page to test if both GET and POST methods work, but only the GET method is retrieving correctly the values. The code is as follows:
The form code:
<form method="post" action="login.php">
<input type="text" name="username"><br>
<input type="password" name="password"><br>
<input type="submit" value="Login">
</form>
In the login.php page, I issue just a simple command to test if there is any value in the $_POST variable:
<?php var_dump($_POST);?>
which turns out to be an empty array.
However, if I change the method to GET, the command
<?php var_dump($_GET);?>
prints the following result:
array (size=2)
'username' => string 'test' (length=4)
'password' => string 'test' (length=4)
I have searched a lot of threads, but most of them were pointing coding errors, which does not seem to be the case here. In any case, if this information is useful, I am using WampServer 2.5 and PhpStorm 10.
Thanks a lot for your help!
Best, Lauro