How can I link directly to a search result?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Denver40
Forum Newbie
Posts: 18
Joined: Tue Dec 02, 2008 9:58 am

How can I link directly to a search result?

Post by Denver40 »

My site sends searches from my main page to another torrent site in frames.
What I'm trying to do is enable the user to link directly to a torrent while staying in my frames, the only way to do this right now is to display a list of results on the external site. They cant link directly to a torrent and stay in frames http://www.plentyoftorrents.com/results ... untu+linux

Can anyone tell me how I could get this working?

Here is the search.php page that handles the form .

Code: Select all

<?php
// grab the search query and request site from the url
 
if($_POST["q"]){
$q = $_POST["q"];
}else{
$q = $_GET['q'];
 
}
$q = htmlentities(stripslashes(trim($q)));
if($_POST['site']){
$site = $_POST["site"];
}else{
$site = $_GET['site'];
 
}
include('switch.php');
 
?>
and here is the switch.php page that handles the sites search strings.

Code: Select all

<?php
// here we use a switch statement to define our url
switch ($site) {
 
 
case "Mininova":
 
$url = "http://www.mininova.org/search/?search=". $q;
 
 break;
 
 
case "Btjunkie":
 
$url = "http://btjunkie.org/search?q=". $q;
 
 break;
 
case "Btleech":
 
$url = "http://btleech.com/search.php?q=". $q ."&cat=&min=min&max=max&submit=Torrents&adv=&br="; 
 
 
 break;
and the search form from the main page.

Code: Select all

 
 
<center><form name="search" action="search.php" method="get">
 
<input type="text" style="width: 155px" name="q">
 
<select name="site" style="width: 140px">
    <option>Mininova</option>
    <option>Btjunkie</option>
     <option>The Pirate Bay</option>
     <option>Bitenova</option>
      <option>Btmon</option>
       <option>btscene</option>
        <option>Isohunt</option>
       <option>Torrentportal</option>
        <option>Torrentvalley</option>
        <option>Fenopy</option>
        <option>Fulldls</option>
       <option>EZTV</option>
       <option>Torrentbox</option>
     <option>Torrentz</option>
     <option>Sumotorrents</option>
     <option>Nutorrent</option>
  </select>
<input type="submit" id="button" style="cursor: pointer;" value="Go...">
</form>
</center>
 
Denver40
Forum Newbie
Posts: 18
Joined: Tue Dec 02, 2008 9:58 am

Re: How can I link directly to a search result?

Post by Denver40 »

Would this be better solved using javascript?
Denver40
Forum Newbie
Posts: 18
Joined: Tue Dec 02, 2008 9:58 am

Re: How can I link directly to a search result?

Post by Denver40 »

bump* :oops:
User avatar
airy
Forum Newbie
Posts: 20
Joined: Fri Jul 11, 2008 2:53 am

Re: How can I link directly to a search result?

Post by airy »

Use $_GET instead of $_POST
then, u can use url like http://www.example.com/search.php?q=keywords
keywords = whatever you want
Denver40
Forum Newbie
Posts: 18
Joined: Tue Dec 02, 2008 9:58 am

Re: How can I link directly to a search result?

Post by Denver40 »

airy wrote:Use $_GET instead of $_POST
then, u can use url like http://www.example.com/search.php?q=keywords
keywords = whatever you want
Ya I did that but that just shows the results in the same way.

I want the user to be able to send a link to a specific result to a friend and still be in my frames.
like this but in my sited frames http://www.mininova.org/tor/2060561

the way it is now they can only send someone this link which shows numurous torrents and not one specific one.
http://www.plentyoftorrents.com/search. ... a&q=Ubuntu

So I guess it would look like this. http://www.plentyoftorrents.com/search. ... or/2060561
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: How can I link directly to a search result?

Post by RobertGonzalez »

You are going to have to be able to capture the search string and when the page is called, run the search inside the frame. On a side note, do you have to use frames for this?
Denver40
Forum Newbie
Posts: 18
Joined: Tue Dec 02, 2008 9:58 am

Re: How can I link directly to a search result?

Post by Denver40 »

Everah wrote:You are going to have to be able to capture the search string and when the page is called, run the search inside the frame. On a side note, do you have to use frames for this?
Does anyone here know how to do that? Yup the frames are the whole way the site works, making it easier for the user to check multiple sites for their torrent. Like if one site doesnt have the torrent all you have to do is go to the top menu and click on another site and it sends the same search query to that site.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: How can I link directly to a search result?

Post by RobertGonzalez »

When you build the frames in the HTML you tell the frames what their source is right? Use the query string to tell the frame what to load.
Denver40
Forum Newbie
Posts: 18
Joined: Tue Dec 02, 2008 9:58 am

Re: How can I link directly to a search result?

Post by Denver40 »

Everah wrote:When you build the frames in the HTML you tell the frames what their source is right? Use the query string to tell the frame what to load.
I wouldnt know how to do that I'm a php noob :oops: . Someone else put most of this php together for me.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: How can I link directly to a search result?

Post by RobertGonzalez »

What you want to do is capture the entire requested URI and send that to the src attribute of the frame you want to load. Frames require a src attribute so they know where their content if coming from. So basically if you take a request like:

http://mysite.com/?q=This+is+a+search

You would want to capture that entire URI and then pass that to the src attribute in the frames HTML of the frame you want to load that into.
Post Reply