2
<a href="index.php?page=test"> Test </a>
<br><br>
<form action="index.php?page=test">
    <input type="text" placeholder="enter text"> </input>
    <button type="submit">Send</button>
</form>

Why is the link working correctly while the form gets me the url http://example.com/index.php? in the adress bar of the browser? Every parameter i define in the action attribute is getting cut off

Philipp
  • 1,001
  • 3
  • 10
  • 10
  • [The HTML5 placeholder attribute is not a substitute for the label element](http://www.456bereastreet.com/archive/201204/the_html5_placeholder_attribute_is_not_a_substitute_for_the_label_element/) – Quentin Jan 15 '15 at 13:23
  • Does this answer your question? [When submitting a GET form, the query string is removed from the action URL](https://stackoverflow.com/questions/1116019/when-submitting-a-get-form-the-query-string-is-removed-from-the-action-url) – miken32 Jun 07 '21 at 22:46

2 Answers2

5

You are submitting a GET form. The data in the form will be expressed as a query string and replace the one in the URL in the action.

Move the data from the query string into hidden inputs inside the form.

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

you have to use this code.

<a href="index.php?page=test"> Test </a>
<br><br>
<form action="index.php" method="get">
    <input type="text" placeholder="enter text"> </input>
    <input type="hidden" name="page" value="test">
    <button type="submit">Send</button>
</form>
Vivek Maru
  • 8,347
  • 1
  • 24
  • 34