What if you set query parameters in the action attribute of an HTML form?
Let us find out.
For example:
<form action="https://show.ratufa.io?ref=contact&type=query" method="post">
...
...
</form>
Here we have two query parameters in the action attribute of the form.
Let us try doing it:
See the Pen HTML form action with parameters on CodePen.
If we try entering some values and submitting the form above, you will see that the server side does receive the query parameters ref
and type
.
How do you get the query parameters on the server side? Well, that depends on the server-side zscripting language you use.
In the case of PHP, the $_REQUEST
super global will get you both the fields from the form as well as the query parameters. $_GET
will get you just the query parameters.
Also see: