Hello world.

Im having problems with my companys intranet and can't work it out.

Basically, I've got a html form text field, which I want to be able to search.
I don't want to make a search engine, its already there, I just need the query typed in the field, to redirect to a search engine.
Lets use google as an example.

They have http://www.google.co.uk/search?q=hello+world if someone searched 'hello world'.

Now, on my site, if someone typed 'damn thing work' in the form field and pressed submit, i want it to take them to http://www.google.co.uk/search?q=damn+thing+work

It would need to load into the parent window or a new window.

I've tried using if(isset with header locations etc, doing my head it.
Calling for help!


6 Years
Discussion Span
Last Post by hielo

the easiest approach would be to "instruct" your form to send it directly to google:

<form method="get" action="http://www.google.co.uk/search">
<input type="hidden" name="btnG" value="Google Search"/>
<input type="text" name="q" value=""/>
<input type="submit" name="submit" value="Submit"/>

and if you want it in a new window:

<form target="_blank" method="get" action="http://www.google.co.uk/search">

Now, if you want to do this from your server using php, assuming your form has a field with name="q" :

if( isset($_GET['q']) && !empty($_GET['q']) )
 header('Location: http://www.google.co.uk/search?'.urlencode($_GET['q']) );
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.