0
<form id="searchForm" method="get" action="search.php">
<input type="text" name="keyword" class="text1" value="" placeholder="SEARCH" style="text-align:center;"/>
<input type="hidden" name="site" class="text1" value="www.mysite.com"/>
<input type="submit" class="text2" name="search" value="Search" />
的search.php搜索的內容和結果,應提供作爲一個新的頁面鏈接
<?php
$query = $_POST['keyword'];
$site = $_POST['site'];
$url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
. "q={$query}+Site:{$site}&userip=USERS-IP-ADDRESS";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'my site url');
$body = curl_exec($ch);
curl_close($ch);
$json = json_decode($body);
?>
我想打印搜索結果爲是隻屬於我的網站如鏈接(谷歌搜索結果)