Hey I have a search on my site but I want to make another form. It has a url like this: http://www.google.com/search?hl=en&q=SEARCHSCRIPT where it puts the search term into the URL. Using php how can I tell the form to submit and insert "SEARCHSCRIPT" into the url AND redirect to that page (when "SEARCHSCRIPT" is the term that is entered into the form?) I AM NOT going to use this to avoid using GOOGLE's search or anything like that.
You can send the keywords directly to the URL via GET through the form: <form action="search.php" method="get"> <input name="q" id="q" value="" /> <input type="submit" value="Search" /> </form> HTML: Or if you want to get the search terms through POST you have them already in your script, and want now to redirect the page: header ("Location: http://www.google.com/search?hl=en&q=YOUR-SEARCH-TERMS-HERE"); exit(); PHP: Hope this helps. Boby
It did work in the google example, but the problem is that my URL is actually: http://www.mydomain.com/index.php?option=com_sobi&task=search&Itemid=99999999&search_str=EXAMPLESEARCH&search_in=city&sobi_order=name I don't know how to make it insert in the middle, and when i put the long string in there it added %20 etc etc ? thanks in advance guys@
Then you have to get first the search terms, build the URL with the search terms in the middle and redirect. For example consider this: $searchTerms = (!empty ($_REQUEST['search']) ? trim (urldecode ($_REQUEST['search'])) : ''); $url = 'http://www.mydomain.com/index.php?option=com_sobi&task=search&Itemid=99999999&search_str='.urlencode ($searchTerms).'&search_in=city&sobi_order=name'; header ('Location: '.$url); exit(); PHP: %20 etc etc come up because the URL is encoded to prevent erros with whitespace and some more chars. Boby
The way you want it...with the keywords in the middle of the url, is some sort of double work. You first have to create a form (action="little-script.php") that sends the data to the a little php script with the code above. This one will then resend the data to a second script (your url) that will do the search.