Web Analytics Made Easy -
StatCounter iframe search engine fail? - CodingForum

Announcement

Collapse
No announcement yet.

iframe search engine fail?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • iframe search engine fail?

    i need to know what the problem with my code is. i have it setup to what every you select from a drop down menu plus a text entry is supposed to equal to the src of the iframe on the second page. please help me to understand why this post method is not working i do not have it hosted so the source code will be quoted:
    Index.php:
    <!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>
    <title>Omni:Search</title>
    <style type="text/css">
    html, body { background-color: black; height: 100%; margin: 0; padding: 0;
    color: white; text-align: center; }
    div#centered {
    border: 0;
    background-color: aqua;
    height: 146px;
    width: 357px;
    position: absolute;
    left: 366px;
    top: 167px;
    color: black;
    }
    </style>
    </head>
    <body>
    <div id="centered" width="400">
    <p><img src="logo.gif" width="327" height="45" alt="ONE SEARCH" /></p>
    <form action="search.php" method="post" >
    <select name="place">
    <option value="http://www.google.com/search?rlz=1C1CHKZ_enUS437US437&amp;q=" selected="selected">google</option>
    <option value="http://search.yahoo.com/search;_ylt=Ap30fQkZEs22unMj49zsCVybvZx4?p=">yahoo</option>
    <option value="http://www.bing.com/search?q=">bing</option>
    <option value="http://www.youtube.com/results?search_query=">youtube</option>
    <option value="http://www.hulu.com/search?query=">hulu</option>
    <option value="http://www.filestube.com/search.html?q=">filestube</option>
    <option value="http://www.kat.ph/search/">kickass torrents</option>
    <option value="http://browse.deviantart.com/?qh=&amp;section=&amp;global=1&amp;q=">deviantart</option>
    <option value="http://en.wikipedia.org/wiki/">wikipedia</option>
    <option value="http://wiki.answers.com/Q/Special:Search&amp;search=">answers</option>
    <option value="http://www.amazon.com/s/?url=search-alias%3Daps&amp;field-keywords=">amazon</option>
    <option value="http://www.ebay.com/sch/i.html?_from=R40&amp;_trksid=p5197.m570.l1313&amp;_nkw=">ebay</option>
    <option value="http://www.tomshardware.com/search.php?s=">toms hardware</option>
    <option value="http://en.search.wordpress.com/?q=">wordpress</option>
    </select>
    <input type="text" name="quiery" />
    <input type="submit" />
    </form>

    </div>
    </body>
    </html>
    Search.php:
    <!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>Untitled Document</title>
    </head>

    <body style="background-color:black;"><div width="100%" height="20%"><table><tbody><tr>
    <td><img src="logo.gif" width="239" height="62" alt="Omni Search" /></td><td><form id="form1" name="form1" method="post" action="search.php" >
    <select name="place" id="place">
    <option value="http://www.google.com/search?rlz=1C1CHKZ_enUS437US437&amp;q=" selected="selected">google</option>
    <option value="http://search.yahoo.com/search;_ylt=Ap30fQkZEs22unMj49zsCVybvZx4?p=">yahoo</option>
    <option value="http://www.bing.com/search?q=">bing</option>
    <option value="http://www.youtube.com/results?search_query=">youtube</option>
    <option value="http://www.hulu.com/search?query=">hulu</option>
    <option value="http://www.filestube.com/search.html?q=">filestube</option>
    <option value="http://www.kat.ph/search/">kickass torrents</option>
    <option value="http://browse.deviantart.com/?qh=&amp;section=&amp;global=1&amp;q=">deviantart</option>
    <option value="http://en.wikipedia.org/wiki/">wikipedia</option>
    <option value="http://wiki.answers.com/Q/Special:Search&amp;search=">answers</option>
    <option value="http://www.amazon.com/s/?url=search-alias%3Daps&amp;field-keywords=">amazon</option>
    <option value="http://www.ebay.com/sch/i.html?_from=R40&amp;_trksid=p5197.m570.l1313&amp;_nkw=">ebay</option>
    <option value="http://www.tomshardware.com/search.php?s=">toms hardware</option>
    <option value="http://en.search.wordpress.com/?q=">wordpress</option>
    </select>
    <input type="text" name="quiery" id="quiery" />
    <input type="submit" name="search" id="search" value="search" />
    </form></td></tr></tbody></table></div>
    <iframe src="<?php echo $_POST["place"]; ?><?php echo $_POST["quiery"]; ?>" width="1024px" height="600px"></iframe>
    </body>
    </html>
    i am editing it in dreamweaver and will publish it soon to omnisearch.tk

  • #2
    for the two different pages, you've copied the same code twice except add an iframe to one page. That's almost defeating the point of PHP.
    In my opinion you should check for $_POST data, and make a conditional based on that to show certain content. For example, you could do:
    PHP Code:
    // I adjusted your spelling
    if(isset($_POST['query'])){
        
    // Form was submitted, display iframe
    }
    else{
       
    // Form wasn't submitted, display form

    That way, all your content is handled by the index.php, saving time and space.

    Regardless, your echo statements are wrong. Instead of breaking up two parts of php, just concatenate your $_POST information in the one query like so:
    PHP Code:
    <iframe src="<?php echo $_POST['place'].$_POST['query']; ?>" width="1024px" height="600px"></iframe>
    The . concatenates the string (appends the second string to the first string). Also note that I changed your quotation marks inside the $_POST values (and the spelling of query again). This isn't essential, but is good practise as php treats " and ' differently. " will evaluate php variables inside them, and ' will treat it as a pure string (which is what you want). ' is slightly faster :P

    But, regardless of all that again, what was the problem exactly? What wasn't working?
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

    Comment


    • #3
      the iframe was giving a file or destination unfound also i would like to use your above method but the form and iframe ar html code and i am unaware as to how to embed html in php code in a way in which it will still function as html and not php script and or text displayed on output. however as of right now the dns is still switching name servers and i am trying to view it locally to test if it might work but this isn't a great way to test considering some of the resources are out on the net but for some reason when i try to view the page in a web browser it just displays the code and or downloads the file instead of outputting the code. so i have a few things to work on i know this is asking a lot but could you compile the completed modified version i have modified the code so far but if i were to want to embed the html in that if else statement then i will need your assistance so here is the modded code.

      index.php:
      <!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>
      <title>Omni:Search</title>
      <style type="text/css">
      html, body { background-color: black; height: 100%; margin: 0; padding: 0;
      color: white; text-align: center; }
      div#centered {
      border: 0;
      background-color: aqua;
      height: 146px;
      width: 357px;
      position: absolute;
      left: 366px;
      top: 167px;
      color: black;
      }
      </style>
      </head>
      <body>


      <div id="centered" width="400">
      <p><img src="logo.gif" width="327" height="45" alt="ONE SEARCH" /></p>
      <form action="search.php" method="post" >
      <select name="place">
      <option value="http://www.google.com/search?rlz=1C1CHKZ_enUS437US437&amp;q=" selected="selected">google</option>
      <option value="http://search.yahoo.com/search;_ylt=Ap30fQkZEs22unMj49zsCVybvZx4?p=">yahoo</option>
      <option value="http://www.bing.com/search?q=">bing</option>
      <option value="http://www.youtube.com/results?search_query=">youtube</option>
      <option value="http://www.hulu.com/search?query=">hulu</option>
      <option value="http://www.filestube.com/search.html?q=">filestube</option>
      <option value="http://www.kat.ph/search/">kickass torrents</option>
      <option value="http://browse.deviantart.com/?qh=&amp;section=&amp;global=1&amp;q=">deviantart</option>
      <option value="http://en.wikipedia.org/wiki/">wikipedia</option>
      <option value="http://wiki.answers.com/Q/Special:Search&amp;search=">answers</option>
      <option value="http://www.amazon.com/s/?url=search-alias%3Daps&amp;field-keywords=">amazon</option>
      <option value="http://www.ebay.com/sch/i.html?_from=R40&amp;_trksid=p5197.m570.l1313&amp;_nkw=">ebay</option>
      <option value="http://www.tomshardware.com/search.php?s=">toms hardware</option>
      <option value="http://en.search.wordpress.com/?q=">wordpress</option>
      </select>
      <input type="text" name="query" />
      <input type="submit" />
      </form>

      </div>
      </body>
      </html>
      search.php:
      <!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>Results</title>
      </head>

      <body style="background-color:black;">
      <div width="100%" height="20%"><table><tbody><tr>
      <td><img src="logo.gif" width="239" height="62" alt="Omni Search" /></td><td><form id="form1" name="form1" method="post" action="search.php" >
      <select name="place" id="place">
      <option value="http://www.google.com/search?rlz=1C1CHKZ_enUS437US437&amp;q=" selected="selected">google</option>
      <option value="http://search.yahoo.com/search;_ylt=Ap30fQkZEs22unMj49zsCVybvZx4?p=">yahoo</option>
      <option value="http://www.bing.com/search?q=">bing</option>
      <option value="http://www.youtube.com/results?search_query=">youtube</option>
      <option value="http://www.hulu.com/search?query=">hulu</option>
      <option value="http://www.filestube.com/search.html?q=">filestube</option>
      <option value="http://www.kat.ph/search/">kickass torrents</option>
      <option value="http://browse.deviantart.com/?qh=&amp;section=&amp;global=1&amp;q=">deviantart</option>
      <option value="http://en.wikipedia.org/wiki/">wikipedia</option>
      <option value="http://wiki.answers.com/Q/Special:Search&amp;search=">answers</option>
      <option value="http://www.amazon.com/s/?url=search-alias%3Daps&amp;field-keywords=">amazon</option>
      <option value="http://www.ebay.com/sch/i.html?_from=R40&amp;_trksid=p5197.m570.l1313&amp;_nkw=">ebay</option>
      <option value="http://www.tomshardware.com/search.php?s=">toms hardware</option>
      <option value="http://en.search.wordpress.com/?q=">wordpress</option>
      </select>
      <input type="text" name="query" id="query" />
      <input type="submit" name="search" id="search" value="search" />
      </form></td></tr></tbody></table></div>
      <iframe src="<?php echo $_POST['place'].$_POST['query']; ?>" width="1024px" height="600px"></iframe>

      </body>
      </html>
      ps the only diffence between the codes is the layout and design of the page

      Comment


      • #4
        Have you checked what is actually being placed into the iframe? 'view source' in the browser and have a look at the iframe and check that the values put into the src attribute are what you expect.
        Useful function to retrieve difference in times
        The best PHP resource
        A good PHP FAQ
        PLEASE remember to wrap your code in [PHP] tags.
        PHP Code:
        // Replace this
        if(isset($_POST['submitButton']))
        // With this
        if(!empty($_POST))
        // Then check for values/forms. Some IE versions don't send the submit button 
        Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

        Comment


        • #5
          it works sorta... check it out at omnisearch.tk

          first id like to point out that on the search.php that works but index.php only loads the 'place' and forgets to load the 'query'

          what i would like to do is to make the index layout load and then after someone enters a query and submits it, it loads the search.php layout do you know how to make this happen if so could you type some code examples that i could use.

          index.php:
          PHP Code:
          <html>
          <
          head>
                <
          title>Omni:Search</title>
          <
          style type="text/css">
                   
          htmlbody   background-colorblackheight100%; margin0padding0;
                                  
          colorwhitetext-aligncenter; }
                   
          div#centered {
              
          border0;
              
          background-coloraqua;
              
          height118px;
              
          width357px;
              
          positionabsolute;
              
          left366px;
              
          top167px;
              
          colorblack;
          }
                </
          style>
             </
          head>
          <
          body>


                <
          div id="centered" width="400">
                  <
          p><img src="logo.gif" width="350" height="65" alt="OMNI SEARCH" /></p>
                  <
          form action="search.php" method="post" >
                    <
          select name="place">
                      <
          option value="http://www.google.com/search?rlz=1C1CHKZ_enUS437US437&amp;q=" selected="selected">google</option>
                      <
          option value="http://search.yahoo.com/search;_ylt=Ap30fQkZEs22unMj49zsCVybvZx4?p=">yahoo</option>
                      <
          option value="http://www.bing.com/search?q=">bing</option>
                      <
          option value="http://www.youtube.com/results?search_query=">youtube</option>
                      <
          option value="http://www.hulu.com/search?query=">hulu</option>
                      <
          option value="http://www.filestube.com/search.html?q=">filestube</option>
                      <
          option value="http://www.kat.ph/search/">kickass torrents</option>
                      <
          option value="http://browse.deviantart.com/?qh=&amp;section=&amp;global=1&amp;q=">deviantart</option>
                      <
          option value="http://en.wikipedia.org/wiki/">wikipedia</option>
                      <
          option value="http://wiki.answers.com/Q/Special:Search&amp;search=">answers</option>
                      <
          option value="http://www.amazon.com/s/?url=search-alias%3Daps&amp;field-keywords=">amazon</option>
                      <
          option value="http://www.ebay.com/sch/i.html?_from=R40&amp;_trksid=p5197.m570.l1313&amp;_nkw=">ebay</option>
                      <
          option value="http://www.tomshardware.com/search.php?s=">toms hardware</option>
                      <
          option value="http://en.search.wordpress.com/?q=">wordpress</option>
                    </
          select>
                    <
          input type="text" name="query" />
                    <
          input type="submit" />
                  </
          form>
                   
             </
          div>
          </
          body>
          </
          html
          search.php:
          PHP Code:
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
          <head>
          <style>
          *{margin:0;padding:0}
          html, body {height:100%;width:100%;overflow:hidden}
          table {height:100%;width:100%;table-layout:static;border-collapse:collapse}
          iframe {height:100%;width:100%}

          .header {border-bottom:1px solid #000}
          .content {height:100%}
          </style>
          </head>
          <body>
          <table>
            <tr><td class="header"><div align="Center" style="background-color:#000000;"><img src="logo.gif" width="239" height="62" alt="Omni Search" /><form method="post" action="search.php">
                    <select name="place" id="place">
                      <option value="http://www.google.com/search?rlz=1C1CHKZ_enUS437US437&amp;q=" selected="selected">google</option>
                      <option value="http://search.yahoo.com/search;_ylt=Ap30fQkZEs22unMj49zsCVybvZx4?p=">yahoo</option>
                      <option value="http://www.bing.com/search?q=">bing</option>
                      <option value="http://www.youtube.com/results?search_query=">youtube</option>
                      <option value="http://www.hulu.com/search?query=">hulu</option>
                      <option value="http://www.filestube.com/search.html?q=">filestube</option>
                      <option value="http://www.kat.ph/search/">kickass torrents</option>
                      <option value="http://browse.deviantart.com/?qh=&amp;section=&amp;global=1&amp;q=">deviantart</option>
                      <option value="http://en.wikipedia.org/wiki/">wikipedia</option>
                      <option value="http://wiki.answers.com/Q/Special:Search&amp;search=">answers</option>
                      <option value="http://www.amazon.com/s/?url=search-alias%3Daps&amp;field-keywords=">amazon</option>
                      <option value="http://www.ebay.com/sch/i.html?_from=R40&amp;_trksid=p5197.m570.l1313&amp;_nkw=">ebay</option>
                      <option value="http://www.tomshardware.com/search.php?s=">toms hardware</option>
                      <option value="http://en.search.wordpress.com/?q=">wordpress</option>
                    </select>
                    <input type="text" name="query" id="query" />
                    <input type="submit" name="search" id="search" value="search" />
                  </form></div></td></tr>
            <tr><td class="content">
                  <iframe src="<?php echo $_POST['place'].$_POST['query']; ?>" frameborder="0"></td></tr>
          </table>
          </body>
          </html>

          Comment


          • #6
            Really don't understand what you mean by this, as the functionality you're wanting already happens.

            If you understand how forms work, you should know that the index.php submits to search.php, and search.php self-submits. index.php doesn't need to know any queries, as it's the landing page - the page someone will initiate the search from. So by "sort of work", what do you actually mean?

            Also, this forum and us people that help should be treated as a learning resource, not a free code dump.
            Useful function to retrieve difference in times
            The best PHP resource
            A good PHP FAQ
            PLEASE remember to wrap your code in [PHP] tags.
            PHP Code:
            // Replace this
            if(isset($_POST['submitButton']))
            // With this
            if(!empty($_POST))
            // Then check for values/forms. Some IE versions don't send the submit button 
            Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

            Comment


            • #7
              well when you submit type into the test box on the forma and submit it, it only loads the 'place' and not both which i find weird

              and im sorry, i dont mean any disrespect.

              i am very new to coding as well so thats y i have so many problems.

              Comment


              • #8
                Solved

                i used your suggested method and with echo '' and i fixed the problem that i was having also thank you for your assistance.

                Comment


                • #9
                  Edit:
                  No worries
                  Useful function to retrieve difference in times
                  The best PHP resource
                  A good PHP FAQ
                  PLEASE remember to wrap your code in [PHP] tags.
                  PHP Code:
                  // Replace this
                  if(isset($_POST['submitButton']))
                  // With this
                  if(!empty($_POST))
                  // Then check for values/forms. Some IE versions don't send the submit button 
                  Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

                  Comment

                  Working...
                  X
                  😀
                  🥰
                  🤢
                  😎
                  😡
                  👍
                  👎