0

I am running a website based on php on a server run by a large host. My goal is very simple. Include link on my site to google search where I dynamically give the search term.

Starting with the url that appears in the address bar, I've narrowed the syntax down to

http://www.google.com/search?q=test

This works when I type it into the address bar. However, when I launch from the server, it redirects to:

www.google.com/webhp...lots of characters

There are references on the web to webhp being related to a virus but I'm pretty sure my host does not have any viruses on its servers.

Does anyone know proper way to launch simple google search from a link? Is a straight link forbidden? I am Willing to use JS to push link to client if necessary (which I use for google maps at Google's recommendation due to usage limits) but want to keep things as simple as possible. This link is just to save people a few clicks.

Thanks for any suggestions.

user1904273
  • 4,562
  • 11
  • 45
  • 96

1 Answers1

3

Simply use the urlencode Method

<?php
echo '<a href="http://www.google.com/search?q=', urlencode($userinput), '">';
?>

If you wish to do it with Javascript the answer is here: Encode URL in JavaScript?


Try to track down the "Url Rewriting", I think its a virus you need to remove: http://www.ehow.com/how_8728291_rid-webhp.html

WebHP is a computer virus that automatically sets your homepage to a fake Google site, known as Google.com/WebHP. This virus will also randomly open windows or tabs to load this website, as well as generate pop-ups and fake errors. Also installed with this virus is a rootkit which can disable your PC's firewall and other methods of security. If left untreated, the WebHP virus allows hackers to remotely access your computer and steal personal information, such as credit card numbers and email passwords.

Community
  • 1
  • 1
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • ok. That did seem to fix it in that it now loads results. However, it still redirects to webhp. – user1904273 Feb 10 '13 at 03:27
  • see my edit, and check if you have this virus locally and not on the server. Thanks & good luck – Jeremy Thompson Feb 10 '13 at 03:29
  • So there is no legitimate webhp in a google address? Odd thing is using urlencode it does load a valid page of google search results ie www.google.com/webhp#q=Buy+trek+bicycle Don't think I have virus locally as have not observed any other symptoms. The switch to webhp only happens with server link. – user1904273 Feb 10 '13 at 10:01
  • No webhp is definitely a virus. If it didn't produce google search results after it did its naughty business you'd know something was wrong. The malware developers are hiding it from you so you dont suspect anything is wrong. Please read over this: http://www.codinghorror.com/blog/2007/06/how-to-clean-up-a-windows-spyware-infestation.html – Jeremy Thompson Feb 10 '13 at 22:16