Jump to content

Search Function


Bavilo

Recommended Posts

Hello,

I was thinking about adding a search field on my site. A field where i just enter some text, click search, and then a new page pops up with the google results of that query. What i need to know is how to append the following: site:http://mysite.com so it actually calls for "blah blah site:http://mysite.com" Can i do this using php?

Thanks
Mike
Link to comment
Share on other sites

[!--quoteo(post=358064:date=Mar 24 2006, 04:33 PM:name=Bavilo)--][div class=\'quotetop\']QUOTE(Bavilo @ Mar 24 2006, 04:33 PM) [snapback]358064[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hello,

I was thinking about adding a search field on my site. A field where i just enter some text, click search, and then a new page pops up with the google results of that query. What i need to know is how to append the following: site:http://mysite.com so it actually calls for "blah blah site:http://mysite.com" Can i do this using php?

Thanks
Mike
[/quote]


Ya gotta do some URL hacking

Instead of opening google.com, open up [a href=\"http://www.google.com/search?hl=en&q=my+search+term+site%3Amysite.com\" target=\"_blank\"]http://www.google.com/search?hl=en&q=mysea...te%3Amysite.com[/a]

where

[code]
http://www.google.com/search?hl=en&q=
[/code]
Is part of google's parameters and
[code]
my+search+term
[/code]
Is your search term
[code]
+site%3Amysite.com
[/code]
Specifies to search your domain at mysite.com

you can then use
[code]
header("Location: http://www.google.com/search?hl=en&q=my+search+term+site%3Amysite.com");
[/code]
to redirect the browser to your home rolled URL.
Link to comment
Share on other sites

  • 2 years later...
Hi, sorry for the HUGE bump, but I'm having the same trouble. Call me a complete n00b, but I have no idea how to get this to work. I'm using Dreamweaver, and I'm trying to create a search function based on the same idea. Could someone please lay out exactly what I need to do? I'm clueless. Thanks!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.