You are here: Re: fopen() with url and search engine (beginner) « PHP Programming Language « IT news, forums, messages
Re: fopen() with url and search engine (beginner)

Posted by Giovanni R. on 07/03/07 10:19

On Tue, 3 Jul 2007 13:24:23 +0530, "sathyashrayan"
<sathyashrayan@REMOVEggmmaaiill.com> wrote:

> If I want to have my own page with a text
> box and a submit button which searches the google and display those google
> search result links in my web page. Can that be possible?

You need to set the 'q' var in the query string you pass to google.com.

In your page.php:

....
<form action="page.php" ... >
<input name="str" type="text" />
<input type="submit" value="Search" />
</form>

<?php
if (isset($_POST['str'])) {

$str = $_POST['str'])
$fh = fopen('http://www.google.co.in/search?q=' . $str, 'r');
...
fclose($fh);

}
?>

However, if you have already sent any html (eg. that <form>) you should
not print out again the <html>, <head>, <body>, etc, html tags coming
from google.co.in. You should strip them out. Take a look at file() or
file_get_contents() or, better, see <http://www.google.com/apis/>.

Giovanni

--
Advanced PHP Programming? See <http://snipr.com/1nsyy>
Ajax in Practice? See <http://snipr.com/1nsyz>
"I bougth them on Amazon.com, I swear I'll sell them only once."

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация