Results 1 to 8 of 8

Thread: Form Redirection Query

  1. #1
    Join Date
    Aug 2007
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Form Redirection Query

    Hello all,

    I have a form on my website

    echo '<form action="/search.php" method="GET">';

    echo 'Search: <input type="text" name="search">';
    echo '<input type="submit" value="Go!">';

    echo '</form>';

    when the "Go!" is activated I need it to return the input from the user as such

    /search.php?startrow=0&search=whatever

    However no matter what I try, all it will ever return is

    /search.php?search=whatever

    I can't impliment my startrow anywhere. Have tried in the FORM ACTION. Have even tried to rename the INPUT TEXT to reflect, but it just doesn't work.

    Is there a way for me to even get the startrow=0 up after what is submitted by user.

    Much obliged,

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    you can put in a hidden input field
    Code:
    <input type="hidden" name="startrow" value="0">
    but anyone would be able to view that in the source code of the file.

    however I would like to know what the purpose of this startrow is going to be? certainly ifyou are using php to process the form, you shouldn't need an extra input in the form itself?

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    ?>
    <form action="/search.php" method="get">
      <div>
        <input type="hidden" name="startrow" value="0">
        <label>
          Search:
          <input type="text" name="search">
        </label>
        <input type="submit" value="Go!">
      </div>
    </form>
    <?php
    Drop out of PHP parsing mode to output HTML, it makes for neater and more efficient code.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Aug 2007
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    excellent. thank you very much. i have one more question.

    what loop could i use to obtain more than one word entered by the user.

    EG. user enters "My Lovely Horse." Search will only equal "My"

    i have: $search = $_Get['search'] in my code already. What loop could i put around that statement to make it search for any/all words entered by user taking into account the spacing

  5. #5
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    // EDIT
    try this
    Code:
    $search = $_GET['search'];
    echo $search;
    that will tell you exactly what has been put into the search variable.
    if you are only getting the My into the variable then its something in your processing before that is causing only the first word to show up.
    if you get the full string entered, then we would need to see more of your code to determine where the rest of the string is being cut out.


    as for getting everything that is entered in the search. you can use the
    PHP Code:
    str_replace("search_term""replace_with""source"); 
    to replace all of your spaces with a wildcard. however that can return results that you do not want, because it will than search for every word whether it be
    "something", "anything", or "a".
    so you just want to design it in a way to get rid of those common words,
    Last edited by boogyman; 08-30-2007 at 02:30 PM.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Less than ideal: the words would have to be in order. Try:
    Code:
    ... WHERE MATCH (mycolumn) AGAINST ('+my +lovely +horse' IN BOOLEAN MODE);
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Aug 2007
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    this is the code i'm using to send the input from the user to the address bar on a new page where I call $_GET['search']. why would this only pass forward the first word of any input and can you help me solve it?

    echo '<form action="/search.php" method="GET" style="margin-bottom:1px">';

    echo '<a href="/">Home</a> | ';
    echo '<a href="/whatsnew.php?startrow=0">What&#39;s New</a> | ';
    echo '<a href="/newsletter.php">Newsletter</a> | ';

    echo 'Search: <input type="text" name="search">';
    echo '<input type="hidden" name="startrow" value="0">';
    echo '<input type="submit" value="Go!">';

    echo '</form>';

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It doesn't, you're handling it wrong on the server side.

    As I said above, you should break out of PHP parsing mode when writing HTML.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •