|
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."
[Back to original message]
|