Jump to content


Photo

A few problems with this code


  • Please log in to reply
4 replies to this topic

#1 Chris88

Chris88
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 17 August 2006 - 05:16 PM

Hello, the code below is a simple search page that allows me to search on imdb.com and google images in one go, but I have a few small problems with it.

1) The code only works when the "Search" button is clicked, but doesn't work when the "Enter" key is pressed.
2) The searching only seems to work with Internet Explorer, but not with FireFox. With FireFox only the first frame is visible, but not the imdb website.
3) I'd like to have a small gap between the two frames, but it doesn't work no matter where I put <.br> in the code.

Is there anybody here who can help me with that?

Thank you.

<html> 
<head> 
    <title> Search Page </title> 
   </head> 
<body bgcolor="#003399"> 
<center> 

<form action="<?php echo($PHP_SELF); ?>" method="POST"> 
  <font color="#FFFFFF"><strong>Movie Search:</strong></font> <input type="text" name="queryORIGINAL"> 
<input type="submit" value="Search" name="submit"> 
</form> 

<?php 

 $submit = $_POST['submit']; 

  If ($submit) { 
   $queryORIGINAL = $_POST['queryORIGINAL']; 
    str_replace(" ", "+", $queryORIGINAL); 
  echo "<iframe src=\"http://www.imdb.com/find?q=$queryORIGINAL&l;tt=on;nm=on;mx=20\" width=\"90%\" height=\"90%\">"; 
 } 
?> 

<?php 

 $submit = $_POST['submit']; 

  If ($submit) { 
   $queryORIGINAL = $_POST['queryORIGINAL']; 
    str_replace(" ", "+", $queryORIGINAL); 
  echo "<iframe src=\"http://images.google.com/images?svnum=100&hl=en&lr=&imgsz=small%7Cmedium%7Clarge%7Cxlarge&safe=off&q=$queryORIGINAL+poster\" width=\"90%\" height=\"90%\">"; 
 } 
?> 

</center> 
</body> 
</html>


#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 17 August 2006 - 06:28 PM

Hey, ok found out a couple things

1. Not sure why the enter key won't work. will get back to this one.
2. You forgot to close the iframe tags. Internet explorer is ALOT more lenient in this respect
3. Once you clode the tags you can add a space.

Some of the code you repeated so I cut it down a bit. Up to you if you want to use it

<html>
<head>
    <title> Search Page </title>
   </head>
<body bgcolor="#003399">
<center>
<?
if(isset($_POST['submit'])){
?>
<form name=form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
  <font color="#FFFFFF"><strong>Movie Search:</strong></font> <input type="text" name="queryORIGINAL">
<input type="submit" value="Search" name="submit">
</form>
<?
 $submit = $_POST['submit'];
   $queryORIGINAL = $_POST['queryORIGINAL'];
    str_replace(" ", "+", $queryORIGINAL);
  echo "<iframe src=\"http://www.imdb.com/find?q=$queryORIGINAL&l;tt=on;nm=on;mx=20\" width=\"90%\" height=\"90%\"></iframe>";
  echo "<hr>";
  echo "<iframe src=\"http://images.google.com/images?svnum=100&hl=en&lr=&imgsz=small%7Cmedium%7Clarge%7Cxlarge&safe=off&q=$queryORIGINAL+poster\" width=\"90%\" height=\"90%\"></iframe>";
} else {
?>
<form name=form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
  <font color="#FFFFFF"><strong>Movie Search:</strong></font>
  <input type="text" name="queryORIGINAL">
  <input type="submit" value="Search" name="submit">
</form>
<?php
}
?>
</center>
</body>
</html>

Ray

#3 Chris88

Chris88
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 18 August 2006 - 12:52 AM

Thank you very much, craygo.

One more question. Is it possible to use a search string with the search page, like imdb.com?

If you put the following url in the address bar of your browser, then it searches for "matrix" right away when the page loads.

http://www.imdb.com/...=on;nm=on;mx=20

I'm wondering if I can do this with my search page as well, for example: http://mywebsite/search.php?q=matrix

#4 Jocka

Jocka
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationDallas, Texas

Posted 18 August 2006 - 01:25 AM

Yea. just use "$_GET" instead of "$_POST" and change the form method to "GET"

#5 Chris88

Chris88
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 18 August 2006 - 02:20 AM

Thank you Jocka :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users