ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Error after searching site

October 25, 2011 9:20am

Subscribe [4]
  • #1 / Oct 25, 2011 9:20am

    Josh Conner

    51 posts

    My simple search is running fine but when the user clicks the back button in the browser to return to the previous page and start another search, I get this error:

    “The following errors were encountered
    The action you have requested is invalid.”

    My code for the search box looks like this

    <dt id="search-box"></dt>
    <dd class="search-form">
    {exp:search:simple_form channel="products"
    search_in="everywhere" result_page="site/search"}
    <input type="text" name="keywords" value=""
     id="search" placeholder="Search…" size="17" 
     maxlength="100" size="20"
     input type="submit" value="Go"/>
    {/exp:search:simple_form}
    </dd>


    and for the search results page:

    <h1>Search Results</h1>
    </br>
    <dl id="search_results">
    {exp:search:search_results}
    <dt class="text"><a href="http://{title_permalink=">_{title}</a></dt>
    <dd class="text">{product_brief}</dd>
    </br></br>
    {/exp:search:search_results}
    </dl>

    I’ve tried searching the forums and google but can’t seem to find a similar problem.

    I’m running EE 2.3.1

  • #2 / Oct 25, 2011 11:25pm

    Dan Decker

    7338 posts

    Hi jconner,

    I’m sorry this is causing you some trouble. Is there anyway you can post the rendered HTML source form your browser? I’d like to get a look at what’s being output by ExpressionEngine.

    Cheers,

  • #3 / Oct 26, 2011 12:36am

    Josh Conner

    51 posts

    Certainly Dan,

    <! Search>
    </br>
    <dt id="search-box"></dt>
    <dd class="search-form">
    <form method="post" action="http://site.com/"  >
    <div class='hiddenFields'>
    <input type="hidden" name="ACT" value="4" />
    <input type="hidden" name="XID" value="01d7e60074ec735c2217dc2834857ee7a22c099c" />
    <input type="hidden" name="RES" value="" />
    <input type="hidden" name="meta" value="bEL29yU4JUB8bTQY+SoNfDMOzaV51vRBZYOIMC+LI6ctUpvh4/zZAzZJ5eslHquNQD9jUbPn/IyaDkZ8CkUdV89FIVzp0zJClOB01r4+Nr3WR40+tR0bQzBOTWsn6qTaWn8rTY1DmulM3m1yDvYI+0KbVvlrx/6w2z0jkp7IF72xSbITTo+ROrS77wJgfYAgtEx/knuLloKleMkk0X0bEw0p/jtqz3BfFJ064eVXeI3uqgMEXjbfAgC2U03pi3k1Cv8CmD513NVpG5Xpz7Ft4RiA+ZQaDG4TJdHAm+C5bNfTvc9BpP1j/YrqMFtrxQesqDVqSUVTOh/tdMYiISa4NlQSVvhoe2+3/rTE/GeeDXG6l3MWglMwet2FJd2HOtkc" />
    <input type="hidden" name="site_id" value="1" />
    </div>
    
    
    <input type="text" name="keywords" value=""
     id="search" placeholder="Search…" size="17" 
     maxlength="100" size="20"
     input type="submit" value="Go"/>
    </form>
    </dd>
    
    <! End Search>

    I replaced the domain URL with “site” otherwise that’s the HTML code that EE output.

    Thanks,
    Josh

  • #4 / Oct 26, 2011 7:13pm

    Dan Decker

    7338 posts

    jconner,

    I spoke with some of my co-horts around here and this seems to be an issue with the XID value already having been generated. If you click back to the search page and refresh, does the issue clear up?

    Cheers,

  • #5 / Oct 26, 2011 10:46pm

    Josh Conner

    51 posts

    Thanks for getting back to me Dan.

    That is exactly what happens.  After I click back, if I refresh the page it will preform a search.  Can you advise me what I need to do to fix this?

    Josh

  • #6 / Oct 28, 2011 5:50pm

    Kevin Smith

    4784 posts

    This is actually expected behavior, Josh. What Dan was referring to (with the XID) is a security precaution. Each time a form of any kind is generated on your site, it’s given a unique ID, called the XID, that lets EE know this is a genuine form submission being received when you submit the form. If you try to submit another form (or even the same form) with the same XID, it will be rejected by EE.

    You can actually see this behavior on our own site if you search the bug tracker and try to go back a page and submit the search again.

    My recommendation is to design your search results page in a way that displays the search field again so that users can keep going forward rather than back a page to search.

  • #7 / Nov 09, 2011 11:14pm

    Josh Conner

    51 posts

    Thanks for the reply Kevin.  I’m a little confused because I know that on other sites we have developed the search will still work if a user decides to go back one page after preforming a search.

  • #8 / Nov 11, 2011 1:20pm

    Robin Sowell

    13255 posts

    You’re right- I recalled 1.x behaving that way, in any case.  So I took a quick look, as of 2.1.3 the secure forms check wasn’t in there.  I’m sorry it wasn’t changelogged- I checked.  That said, we do want the secure forms check in there- search field do actually get spammed.  And secure forms nips that in the bud.  (Granted, you can turn the check off, but it is a good first level spam preventer.)

    What might make sense is to either have a simple form on the results page, so they can easily do a new search.  Or provide a link to the search page/back page so you get a page refresh- at which point, a new search will be fine.

    Make sense?

  • #9 / Nov 11, 2011 1:23pm

    Robin Sowell

    13255 posts

    Also- AHA.  It was changelogged as a bug fix- 2.1.5 (Build 20110512).

    Fixed a bug where search form XID checking would fail to check in some cases which could lead to lack of garbage collection in the security_hashes table.
    [/code]

  • #10 / Nov 11, 2011 4:28pm

    Josh Conner

    51 posts

    Thanks everyone!  Your help is greatly appreciated.

  • #11 / Nov 12, 2011 5:24am

    Robin Sowell

    13255 posts

    No problem- was good for us to track back that change as well!  If you run into anything else, just let us know!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases