'Submit form, don't show param and value in URL? [duplicate]
I have a simple form and when the select field is changed it submits the form reloading the current page passing the select value to the page.
<form>
<select id='query' name='query' onchange='this.form.submit()'>
<option value=1>1<option>
<option value=2>2<option>
</select>
</form>
This works fine, but the URL then contains pagename.php?query=2
Is there anyway to do this without the parameter and value being seen in the URL ?
Thanks
Solution 1:[1]
When you use form, it has a paramatter that if you dont put nothing, it is METHOD="GET", this makes the petition and sends data from URL, so you should put METHOD="POST":
<form method="post">
<select id='query' name='query' onchange='this.form.submit()'>
<option value=1>1<option>
<option value=2>2<option>
</select>
</form>
You will have to make some more changes in your php, but i don't have enought information about it to help you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Maidagan |
