Jump to content

A few problems with this code


Chris88

Recommended Posts

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.

[code]<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>[/code]
Link to comment
Share on other sites

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

[code]<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>[/code]

Ray
Link to comment
Share on other sites

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/find?q=matrix&l;tt=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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.