Is it okay or correct to put a url get parameter in a form action?
<form method='get' action='index.php?do=search'>
<input name='_search' type='text' value='What are you looking for?'>
<button type='submit'> Search </button>
</form>
When I submit the form the URL is changed to:
index.php?_search=What are you looking for? (I've stripped %20)
I'd prefer the URL to read
index.php?do=search&_search=What are you looking for?
Would it be best to add a hidden field into the form
<input type='hidden' name='do' value='search' />
I think the same as Teodor, there should be no reason to don't send the variable as a hidden field. But in case you have a good reason for doing that... Have you tried adding a & at the end of the url:
In my opinion you should add them as hidden fields. There is no point to try to pass params if you can do it via hidden form field
use that:
A don't see any reason why you can't or shouldn't do it that way. My preferred method of handling it however would be:
The name/value pair of do/search is passed through the button press, and if you want to create multiple actions on a form you can then have different values for each submit button, handling the form in multiple ways.
alternatively you can use a case construct:
I normally use
post
myself, but I am sureget
would work the same way. Hope that answers your question.