WordPress.org

Ready to get started?Download WordPress

Forums

search form not working (6 posts)

  1. biffwebsterjr
    Member
    Posted 4 years ago #

    My search form is not working. In searchform.php I have:

    <form id="searchform" action="<?php bloginfo('url'); ?>/" method="get" role="search">
    	<fieldset>
        	<label for="s">Search apolishson.com</label>
        	<input type="text" name=s"" />
        	<input type="submit" name="submit" value="Search" />
        </fieldset>
    </form>

    I'm pulling it into my header.php with:

    <?php include (TEMPLATEPATH . '/searchform.php'); ?>

    I am pretty new to PHP so I'm sure I am missing something, but when I search for something, it returns me to the homepage with the url 'http://localhost:8888/PolishSonWP/?s%22%22=searchterm&submit=Search'

    What's going on?

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Try using <?php get_search_form();?>

  3. xdesi
    Member
    Posted 4 years ago #

    You can use:

    <?php get_search_form(); ?>

    Rather than the include

    Also you have an typo on your searchform.php whereby:

    name=s""

    should be
    name="s"

    If it's still failing try changing:
    <?php bloginfo('url'); ?>
    to:
    <?php bloginfo('home'); ?>
    Just because my theme has this so might make a difference.

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    should be name="s"

    Oh well spotted!

    FWIW, all of my search forms use <?php bloginfo('url'); ?> and I've never had any problems. However, it might be worth noting that, if you submit an empty search on most themes, you will be sent straight back to the Home page. No error messages. Nothing.

  5. xdesi
    Member
    Posted 4 years ago #

    Yup I still have to implement the helpful fix you've provided to this!

  6. biffwebsterjr
    Member
    Posted 4 years ago #

    I knew it was something little I was overlooking. The name typo was the entire problem. Good eye xdesi. Thanks both of you.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags