Reputation: 79
So I'm trying to learn html+php but it seems like I've hit a wall. If I use the GET method in my html form, parameters are sent to my php file just fine, but if I try to do the same using the POST method no parameters are sent.
@Edit: I've taken down the initial code sample displayed here as I found out its not a problem specific to that code. Instead I'm posting a basic form and a basic php script that have the same problem:
HTML FILE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="testingForm.php" method="POST">
INPUT: <input type="text" id="iTesting" name="nTesting"/><br/>
<input type="submit" value="SUBMIT"/>
</form>
</body>
</html>
PHP FILE:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title></title>
</head>
<body>
<?php
/* THIS WORKS: */
/*if (isset($_GET["nTesting"]))
echo "It is working! ".$_GET["nTesting"];
else
echo "It is NOT working! input: ".$_GET["nTesting"];
echo "<br/>".$_SERVER['REQUEST_METHOD']."<br/>";
echo "<br/>".var_dump($_GET);//*/
/* THIS DOESN'T: */
if (isset($_POST["nTesting"]))
echo "It is working! ".$_POST["nTesting"];
else
echo "It is NOT working! input: ".$_POST["nTesting"];
echo "<br/>".$_SERVER['REQUEST_METHOD']."<br/>";
echo "<br/>".var_dump($_POST);//*/
?>
</body>
</html>
As stated before, if I change the form method to GET, I get no problem at all. However, data doesn't seem to be sent when using POST method.
This is the output using the GET method:
It is working! input: test
GET
array(1) { ["nTesting"]=> string(4) "test" }
This is the output using the POST method:
It is NOT working! input:
POST
array(0) { }
Also, using the developers tool I can see there is a parameter nTesting:test in the formData section of the network tab. Yet, nothing is displayed.
Upvotes: 2
Views: 3435
Reputation: 74
If you're using Chrome
After working with @MuriloRM we ended up with the fundamental bug with PHPStorm
Please vote up the resolution of the issue https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000097930-Can-not-use-POST-method-in-PhpStorm
Upvotes: 2