Search box and links question

Discussion in 'HTML & Website Design' started by fetch-boy, Dec 20, 2007.

  1. #1
    Hi there
    Basically I've got a search form on my website www(.)fetch-boy(.)com, which is:

    <input type=text name=q size=50 value="">

    and a link further down the page linking to another site which has a search facility. What I need to do is when a user has entered a search phrase in the search box, and is taken to the results page (which is still on my site), I want the other link that I mentioned above to somehow call what their search-phrase was, so it is part of the url i.e. www.the other website with a search box.com/?q=search phrase. So basically the search box on that site is prefilled with the search phrase they used on my site.

    I think it's probably to do with "q", but I don't know what html I'd use to incorporate it in the url, but I expect it's simple lol. Hope this all makes sense, and thanks in advance for any help :)
     
    fetch-boy, Dec 20, 2007 IP
  2. jDare

    jDare Guest

    Messages:
    218
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If I understand your question on how to dynamically put their search phrase into the destination url, I don't believe you can do this with HTML. You'd have to use a server side script like php, asp, cold fusion, or even javascript can do it. Are you familiar with any other coding languages and will your server support any of these?
     
    jDare, Dec 20, 2007 IP
  3. twistedspikes

    twistedspikes Notable Member

    Messages:
    5,694
    Likes Received:
    293
    Best Answers:
    0
    Trophy Points:
    280
    #3
    Yes you would have to use a server side script such as php to do this. It is pretty simple to implement if your site is already dynamicly driven.
     
    twistedspikes, Dec 20, 2007 IP
  4. fetch-boy

    fetch-boy Active Member

    Messages:
    139
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Thanks for the help guys. I think maybe I wasn't clear enough on it. To make it clearer (I hope), basically I want to take a search phrase that someone has searched for, and make it appear elsewhere on the page. For instance, much like a search engine - when you've typed in the phrase you're searching for, the next page says "Your search phrase ***** returned x results". I want to know how to get the ***** part to show in a separate part of text on a page.

    Thanks again :)
     
    fetch-boy, Jan 1, 2008 IP
  5. jDare

    jDare Guest

    Messages:
    218
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    One way of doing it with PHP would be the following:

    In the first page add a form with a simple input field:
    <form method="POST" action="Page2.htm">
    <input type="text" name="Keyword">
    <input type="submit">
    </form>
    Code (markup):
    Then on page2 (where ever you want the keyword to be shown) ad this:
    <?php
    if (isset($_POST['Keyword']) && $_POST['Keyword'] != '')
    {
    echo $_POST['Keyword'];
    }
    ?>
    Code (markup):
    The if statement helps to prevent a php code error when that variable has not been set. This can happen if some one goes directly to that page or does not use the form to get to that page. I haven't tested this code but it looks like it would work. :)
     
    jDare, Jan 2, 2008 IP
    fetch-boy likes this.
  6. fetch-boy

    fetch-boy Active Member

    Messages:
    139
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #6
    Brilliant thanks for your help, I'll have a go at that :)
     
    fetch-boy, Jan 3, 2008 IP