Need to pass a variable in a search box

Discussion in 'PHP' started by vetting, Aug 7, 2008.

  1. #1
    I have a variable in the url of ?refid=



    I need to pass the value of this in a search box.
    <form method="get" action="/search/">
    <input type="text" value="" class="text" size="16" name="search">
    <input type="submit" value="Go" class="searchbutton">
    </form>

    How do I grab the variable out and insert it into the form before it is submitted?
     
    vetting, Aug 7, 2008 IP
  2. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #2
    
    <input type="text" name="my_field" value="<?php echo $_GET['refid'];?>" />
    
    Code (PHP):
     
    rohan_shenoy, Aug 7, 2008 IP
  3. vetting

    vetting Peon

    Messages:
    193
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Tweaked it a bit and got it working - thanks again for your help.

    <form method="get" action="/search/">
    <input type="text" value="" class="text" size="16" name="search">
    <input type="hidden" name="ref" value="<?php echo $_GET['ref'];?>" />
    <input type="submit" value="Go" class="searchbutton">
    </form>
     
    vetting, Aug 8, 2008 IP