-1

I have just a quick question. Does someone know why this html page (a form) does not work?

<html>
<head></head>
<body>
<form method=POST action=show-query-params>
<p>
<input type=text name=foo id=foo size=20 value=nameee />
</p>
<p>
<input name=submit type=submit value=submit />
<input type=reset value=Reset />
</p>
</form>
</body>
</html>

When I click submit, the page "http://localhost:8080/show-query-params" is opened but with no parameters. Thanks in advance!

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
DidacC
  • 93
  • 2
  • 13

2 Answers2

0

Data gets added to the query string of the URL when you submit a form with method="GET" (the default).

You have set method="POST" so the data be will placed in the request body and not visible in the URL.

You can inspect it using the Network tab in your browser's Developer Tools.

See also: When should I use GET or POST method? What's the difference between them?.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

You need to understand the difference between GET and POST parameters. A GET parameter appears after the URL in your browser window, as you expected. A POST parameter will not appear after the URL.

You can change your method to GET at your form tag to reach the behavior you desire.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175