Objective:
- Creating a simple PHP Widget, which will allow the user to reach the result page of Google! from your site.
Requirement:
- Adobe Dreamweaver or any Open Source Editor like Aptana Studio, Amaya, etc.
Creating the form(index.htm):
<form action=“google.php” method=“get” name=“query_form”>
<input id=“search” onclick=‘value=”” ‘ name=“search” type=“text” value=“Enter the search term” />
<input id=“submit” name=“submit” type=“submit” value=“Submit” />
</form>
PHP Script(google.php):
<?PHP
$url=“http://www.google.com/search?q=”.$_REQUEST[‘search’];
header(“Location:$url”);
?>
Download the full script, here
Even you can create more widgets just by changing the URLs. I’m mentioning few search URLs:
- Yahoo Search : http://search.yahoo.com/search?q=
- Live Search : http://search.live.com/results.aspx?q=
- Youtube : http://www.youtube.com/results?search_query=
- Answers : http://www.answers.com/topic/
- Wikipedia : http://en.wikipedia.org/wiki/
Thanks to SachinKRaj for guiding me on this script. Do post your comments 🙂
Filed under: General, Latest News, php, PHP Widgets, Tech News, weblog, Website | Tagged: create php widget, dreamweaver, php, php header(), php tutorial |
Nice Tips.
See you around 🙂
thank’s
how do u make it so that if you have two values, its combined and sent to the url .. like…
two boxes for search field keywords… “keyword 1 ” and “keyword 2”
then it processes to be Keyword 1 and keyword 2
Very great tip, btw.