Jnerocorp Posted November 4, 2009 Share Posted November 4, 2009 Here is the code: Index.php <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Custom Google Search Page</title> <meta name="description" content="Custom Google Search Page" /> <meta name="keywords" content="custom, google, search, page" /> <script type="text/javascript" src="includes/js.php"></script> <link href="images/home.css" rel="stylesheet" type="text/css" /> <!--[if lte IE 6]> <link href="images/ie6.css" rel="stylesheet" type="text/css" /> <![endif]--> <style type="text/css"> .searchresult { padding: 1.5em 0; border-bottom: 1px solid #333; } .searchresult h3, .searchresult p { margin: 0; } .searchresult h3 a { font: italic 1em Georgia, serif; color: #f30; border-bottom: 1px solid #900; text-decoration: none; font-weight: bold; font-size: 1em; } .searchresult .resultdesc b { color: #fff; } .searchresult .resulturl { color: #666; font-size: .75em; } </style> </head> <body> <div id="wrapper"> <div id="bg_t"> </div> <div id="bg_c"> <div id="logo"> <a href="./index.php"><img src="./images/logo.png" border="0"></a> </div> <form method="get" action="querygoogle.php"> <div id="search"> <label for="searchquery"><span class="caption">Search this site</span> <input type="text" size="20" maxlength="255" title="Enter your keywords and click the search button" name="searchquery" /></label> </div> <div id="buttom"> <input type="submit" value="Search" /> </form> </div> </form> <br><br> <?php if(!empty($_SESSION['googleresults'])) { echo $_SESSION['googleresults']; unset($_SESSION['googleresults']); } ?> <div id="newkey"> <div class="searchnew"> <br clear="all" /> </div> <div class="searchnew_b"> </div> </div> </div> <div id="bg_b"> </div> <div id="footer"> Copyright © 2009 by <strong>Domain.com</strong>. All rights reserved - Script by: <a href="http://prophpdev.net/"><strong>ProPHPDev.net</strong></a> </div> </div> </body> </html> querygoogle.php: <?php session_start(); if(isset($_GET['searchquery'])) { // if you use an Mike Migurski's JSON library, include it like I did require_once('JSON.phps'); // Here's the Google AJAX Search API url for curl. It uses Google Search's site:www.yourdomain.com syntax to search in a specific site. I used $_SERVER['HTTP_HOST'] to find my domain automatically. Change $_POST['searchquery'] to your posted search query $url = 'http://ajax.googleapis.com/ajax/services/search/web?rsz=large&v=1.0&q=' . $_GET['searchquery'] . ''); // use fopen and fread to pull Google's search results $handle = fopen($url, 'rb'); $body = ''; while (!feof($handle)) { $body .= fread($handle, 8192); } fclose($handle); // now $body is the JSON encoded results. We need to decode them. $json = new Services_JSON(); $json = $json->decode($body); // now $json is an object of Google's search results and we need to iterate through it. foreach($json->responseData->results as $searchresult) { if($searchresult->GsearchResultClass == 'GwebSearch') { $formattedresults .= ' <div class="searchresult"> <h3><a href="' . $searchresult->unescapedUrl . '">' . $searchresult->titleNoFormatting . '</a></h3> <p class="resultdesc">' . $searchresult->content . '</p> <p class="resulturl">' . $searchresult->visibleUrl . '</p> </div>'; } } $query = $_GET['searchquery']; $murl = "http://mydomainpagerank.com/search2/index.php?q=$query"; $_SESSION['googleresults'] = $formattedresults; header('Location: ' . $murl); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/180313-header-location-redirect-is-not-redirecting-no-error-message/ Share on other sites More sharing options...
ram4nd Posted November 4, 2009 Share Posted November 4, 2009 isset($_GET['searchquery']) is it set? Link to comment https://forums.phpfreaks.com/topic/180313-header-location-redirect-is-not-redirecting-no-error-message/#findComment-951207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.