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
https://forums.phpfreaks.com/topic/5718-search-function/
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
https://forums.phpfreaks.com/topic/5718-search-function/#findComment-20418
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
https://forums.phpfreaks.com/topic/5718-search-function/#findComment-638762
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.