Advanced Search

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: "form" help.

  1. #11
    Join Date
    Jan 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i droped it into the root to see if that helped anything.. it didn't. heres the link.

    http://unknownerrors.net/searchform.php

  2. #12
    Join Date
    Jan 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    very weird, when i make the search page in Dreamweaver, the form action is set to <?php echo $_SERVER['PHP_SELF'];?>

    once up loaded to the server, if you view source the action is changed to what ever the file name of the search page is.

  3. #13
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Sounds like dreamweaver.

    Try doing it in notepad. (you can copy and paste). DW has a knack for parsing scripts during publishing, which is a bad thing.

    See what happens if you do it in a plain text editor.
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #14
    Join Date
    Jan 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    wow, never realized how much crap DW puts in its files.

    anywho,

    this is what the file i made looks like.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 
    
    Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; 
    
    charset=iso-8859-1">
    </head>
    <body>
    
    
    <?php
    if ($_POST['act'] == "do_search") { //if the action is 
    
    do_search
       if ($_POST['q'] == "" || $_POST['se'] == "") { //if 
    
    query or search engine is blank
            header('Refresh:3; url='.$_SERVER["PHP_SELF"]);
            echo 'You must enter a search query and select a 
    
    search engine to search!';
       }
    
       else {
    
    header('Location: '.$_POST["se"].$_POST["q"]);
    
       }
          
    }
    
    else { //if form not submitted
    ?>
    
    <form action="<?php echo $_SERVER['PHP_SELF'];?>" 
    
    method="POST">
    <input type="hidden" name="act" value="do_search">
    
    Search: <input type="text" name="q" value=""><BR>
    <input type="radio" name="se" value=" 
    
    http://www.google.com/search?hl=en&btnG=Google+Search&q=">G
    
    oogle <input type="radio" name="se" 
    
    value="http://hotbot.com/?loc=searchbox&tab=web&mode=search
    
    &currProv=ask&query=">HotBot<BR>
    <input type="submit" value="Search">
    
    </form>
    
    <?php
    }
    ?>
    </body>
    </html>
    Now, this is what the file looks like on the server.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    
    
    
    <form action="/searchform.php" method="POST">
    <input type="hidden" name="act" value="do_search">
    
    Search: <input type="text" name="q" value=""><BR>
    <input type="radio" name="se" value=" http://www.google.com/search?hl=en&btnG=Google+Search&q=">Google <input type="radio" name="se" value="http://hotbot.com/?loc=searchbox&tab=web&mode=search&currProv=ask&query=">HotBot<BR>
    
    <input type="submit" value="Search">
    
    
    
    </form>
    
    
    </body>
    </html>
    theres some code missing.. how is it getting lost from my computer to smartftp though my server to my browser?!

  5. #15
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Well, php is a server-side language. Everything in php coding tags is being parsed/read before it get's to the browser.

    The browser's source code only displays what you actually physically see on the page (in reference to html vs. php here)

    So anything between the <?php and the ?> won't show in the source code. Unless you TELL php to show some things, i.e. the echo ' statement.
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #16
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Ok, here's a for sure working version. Just edit the parts in red (commented) to suit your needs.

    search.php
    Code:
    <?php
    
    /* Below is the header section (the part before the search form) of your page. Place it between the HERE tags! */
    
    $head = <<<HERE
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    HERE;
    
    /* Below is the footer section (the part after the search form) of your page. Place it between the HERE tags! */
    
    $footer = <<<HERE
    
    <iframe src="" name="myFrame"></iframe>
    </body>
    </html>
    HERE;
    
    if ($_POST['act'] == "do_search") { //if the action is do_search
       if ($_POST['q'] == "" || $_POST['se'] == "") { //if query or search engine is blank
            header('Refresh:3; url='.$_SERVER["PHP_SELF"]);
    
    echo $head;
    
    echo 'You must enter a search query and select a search engine to search!';
    
    echo $footer;
    
       }
    
       else {
    
    header('Location: '.$_POST["se"].$_POST["q"]);
    
       }
          
    }
    
    else { //if form not submitted
    
    echo $head;
    ?>
    
    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" target="myFrame">
    <input type="hidden" name="act" value="do_search">
    
    Search: <input type="text" name="q" value=""><BR>
    <input type="radio" name="se" value=" http://www.google.com/search?hl=en&btnG=Google+Search&q=">Google <input type="radio" name="se" value="http://hotbot.com/?loc=searchbox&tab=web&mode=search&currProv=ask&query=">HotBot<BR>
    <input type="submit" value="Search">
    
    </form>
    
    <?php
    echo $footer;
    }
    ?>
    To see what it does, go to this page (Note, this is my home server. If you can't access it, I may be doing updates or it is turned off.)

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #17
    Join Date
    Jan 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    works like a charm.. thank you very much.

  8. #18
    Join Date
    Jan 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    if you want to see what you guys help turned into.

    http://alphapirates.com/

    far from completed. but working.

  9. #19
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Great, at least it's working for you. Let us know if you need any more help.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  10. #20
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Nice. And it works too

    Check the spacing in the <title> though
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •