Append input name value to url string when posting

Basically I have been asked by our systems guy here for the sake of analytics to add the value from a search to the url string so we can track the keywords searched.

So i have the code below which works fine, but I dont know how to append the value of the input to the url string.

    <form name="search" method="post" action="result_Search.php">    
    <input type="text" value="Search By Safe Hotels..." onfocus="this.value = (this.value == 'Search By Safe Hotels...') ? '' : this.value;" onblur="this.value = (this.value == '') ? 'Search By Safe Hotels...' : this.value;" style="position:relative; float:left; width:223px; margin-left:2px; height:21px; color:#000;" name="find" />
    <input type="image" src="site_images/search_Button_Little.png" alt="Submit Form" />
    <input type="hidden" name="searching" value="yes" />

So for instance, if the user enters ‘bristol’ in to the search, when they click submit the url will be liek this:


So its getting the value out of the input name title ‘find’ and adding it to the url.

Currently you are using the POST method to submit the form data. If you want the data to be in the url, then you can use the GET method to submit the form data instead, and adjust your PHP script to retrieve the info accordingly.

<form name="search" method="get" action="result_Search.php">

Hi Paul,

Good to hear form you again.

Thats part of the problem really, as putting the value in the url has no benefit to the site, only in an analytics sense.

The whole site is set up to deal with POST and so ideally, I need to keep it like that, but for analytics reasons have the value also in the URL.


There are other solutions - such as submit the form to an intermediary page via GET, which can then automatically redirect to a submit via POST while keeping the values in the URL.
Or, you can submit via POST and have the server-side script redirect to the same page with the values in the URL.

IMHO though the easiest solution is to submit via GET, from where you can then direct the information to where it needs to be.

It also benefits your users, as with the params in the URL they can bookmark a particular search and return to it later (or share it with someone else).

Yes thank you,

I’m glad also that there isnt a sort of easy way that I missed.

Will look into this and like fretburner syas its also good for bookmarking, so will mention it to the systems guy.

Thanks guys

forgive me if this beyond the scope of this but thought it would be worth a mention.
ideally what you want is to use GET and then on the server have it change the URL to be or maybe
this makes it much easier for a user and still good for search engines