I have a search form with a submit button that looks like this:
<input type="submit" name="search_submit" value="Go"/>
I use the following php to handle this form:
if (isset($_GET['search_submit'])) { do blah }
Works fine. But my URL then contains &search_submit=Go. I don't want it to show up.
I know that to fix this problem I need to remove the name attribute from the form input row.
But my php doesn't work anymore and I don't know how to change it to handle the form. I tried changing it to:
if (isset($_GET['submit']))
and
if (isset($_GET['Go']))
But they don't work either. It would be great if someone could help me answer this.
If you don't want to display the string in the
URL
, you can use thePOST
method. The main differences betweenGET
andPOST
are as follows:Obtain:
release:
Sample code:
You cannot remove the name of an input element because PHP doesn't know which value to look for. If you want to completely hide the string behind the URL, use Request method POST
GET
:Your PHP will use the following:
A good answer on when to use GET and POST can be found here.
EDIT: If you just don't want the button to show up in the URL, but everything else should still be there (as per your comment), you can simply remove both The value and name of the submit button.
You can look for other values instead of looking for the one to set
search_submit
: