Search box code problem

by 4 replies
5
I cant get this figured out?? I need my search box to create a specific url when submitted. How would I edit the code below so a search for 'steve jones' returns this URL: http://blogname.com/ticket-tag/steve-jones/

HTML Code:
<form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
    <div><label class="screen-reader-text" for="s">Search for:</label>
        <input type="text" value="" name="s" id="s" />
        <input type="submit" id="searchsubmit" value="Search" />
    </div>
</form>
#programming #box #code #problem #search
  • The data from your form needs to be converted into an URL by the page you are submitting to.

    Are you using some kind of custom function? Because I'm not familiar with this function. And php.net says it doesn't exist.
  • The url format that you are requesting is not in standard cgi format. You can use JavaScript to take the data from the form, and change it to the format you want.

    Alternatively, you can program the server side app to take both your desired url format, AND a corresponding cgi style request. That way this would not require JavaScript running on the browser.

    (The cgi style url would look like: http://myDomain.com/myPhpScript.php?name=steve+jones

    Harrison
  • Thanks guys! I'll get to work.
  • I'm not quite sure what you mean, but I'll go with what I got. Do you
    mean a pre-set value?

Next Topics on Trending Feed

  • 5

    I cant get this figured out?? I need my search box to create a specific url when submitted. How would I edit the code below so a search for 'steve jones' returns this URL: http://blogname.com/ticket-tag/steve-jones/ HTML Code: <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>"> <div><label class="screen-reader-text" for="s">Search for:</label> <input type="text" value="" name="s" id="s" /> <input type="submit" id="searchsubmit" value="Search" /> </div> </form>