Search code examples
htmlformsgetsubmitaction

form action parameter not working


<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


Solution

  • 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>