By desm0n on
Everytime i submit a search through my themes search forms i get
Validation error, please try again. If this error persists, please contact the site administrator.
I had previously hard coded this search field and obviously something changed in the search that effects my custom search form.
Heres what i had as my search form in the page.tpl.php template
<div class="search_field">
<form action="?q=search/node/" method="post">
<p><span class="grey">Search Example:</span> <span class="search">Port Talbot Chat </span>
<input type="text" maxlength="128" name="edit[search_theme_form_keys]" id="edit-search_theme_form_keys" size="15" value="" title="Enter the terms you wish to search for." class="search" />
<input type="submit" name="op" value="Search" class="button" />
<input type="hidden" name="edit[form_id]" id="edit-search-theme-form" value="search_theme_form" />
</p></form></div>Checking i see some of the ID's have changed so i altered them to look like this -
<div class="search_field">
<form action="/search/node" method="post" id="search_form" class="search-form">
<p><span class="grey">Search Example:</span> <span class="search">Port Talbot Chat </span>
<input type="text" maxlength="128" name="edit[keys]" id="edit-keys" size="15" value="" title="Enter the terms you wish to search for." class="search" />
<input type="submit" name="op" value="Search" class="button" />
<input type="hidden" name="edit[form_token]" id="edit-form_token" value="2220bb15109dedb92c709e240dccdaf1" />
<input type="hidden" name="edit[form_id]" id="edit-search-form" value="search_form" />
</p></form></div>This now works in firefox but not in Internet Explorer. Anyone tell me where i'm going wrong ?
4.7.4 is turning out to be a real headache ...
Comments
Add the following code
Add the following code before the closing form tag.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.
Hi Heine and thanks for
Hi Heine and thanks for getting back to me. I assumed it was to do with the token but i can't seem to get it quite right here.
I now have it outputting a unique token but its still not working using the snippet you provided.
I added your snippet in place of the
<input type="hidden" name="edit[form_token]" id="edit-form_token" value="2220bb15109dedb92c709e240dccdaf1"and tried both with the id="edit-form_token" and id="a-unique-id" but still get the same. Heres my current code -
and my output is
What am i missing ?
--
http://www.porttalbotchat.co.uk
-------------------------------------------------
Our mission is to discuss issues and topics of residents of Port Talbot. We provide info on events, issues, concerns and discussions of our local area.
Just to add this is hard
Just to add this is hard coded into page.tpl.php, could this be the issue ? its been there for many months and never had an issue.
The token seems to be generating but the site is not validating it.
--
http://www.porttalbotchat.co.uk
-------------------------------------------------
Our mission is to discuss issues and topics of residents of Port Talbot. We provide info on events, issues, concerns and discussions of our local area.
My modification started from
My modification started from the first code block you posted, not the second. Apologies if that caused confusion.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.
aha, that did the trick,
aha, that did the trick, many thanks for that.
However if you could, if you have the time that is, i'm curious the difference between the two bits of code. Why didn't the token work for the second bit of code and yet does for the first ?
UPDATE: ah would the second one have been
<input type="hidden" name="edit[form_token]" id="a-unique-id" value="<?php print drupal_get_token('search_form'); ?>" />--
http://www.porttalbotchat.co.uk
-------------------------------------------------
Our mission is to discuss issues and topics of residents of Port Talbot. We provide info on events, issues, concerns and discussions of our local area.
Also - For Trip Search (SQL Search)
For trip_search (SQL Search) add this to your form instead:
--
wOOge | axondesignstudio.com
--
wOOge | adrianjean.ca
Validation error, please try again. on 5.2
Heine, (If you're still out there) I'm having the same problem on a fresh upgrade to 5.2. My themed search form works on my dev site without any kind of edit[form_token] hidden field. But when I move my search-form.tpl.php file to the live server, I get the validation error.
When I add:
to my custom template, it still works on my dev site, but when moved to the live server it still fails.
Any hints for me?
Thanks in advance,
Jen
Drupal 5
The output of FAPI changed a little in Drupal 5:
It's very odd that it fails on the live site and not on the dev site. Perhaps running a diff (diff -uprN folder_live folder_dev) can shed some light on this.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.
that still didn't work...
Heine,
I think that code you supplied was for the search-box. I'm trying to theme the advanced search page. so I'd guess it needs to be more like this:
...and magically, it works now!
Jen
<?php print drupal_get_token('search_theme_form') ?>
hi, i might be silly, i am still a newby
i am facing the same problem, can you please explain to me how can i add
print drupal_get_token('search_theme_form')to the code drupal is generating in the search form. thanksCode?
If you let drupal generate the form, there's nothing you need to do. If not, best post the code.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.
Cookie?
Had the same problem on Drupal 5.5 - had 3 tabs open with the same site, got the error, Googled it and found somewhere the remedy that worked for me - just restart the browser, it seems it's something to do with cookies FAPI uses
Jacob.
Thank-you very much!!! This
Thank-you very much!!! This has been driving me mad and now search works perfectly.
This worked for me too.
This worked for me too. Insert after the submit button.
Still won't work.
Restart browser.
Works now =D
(Drupal 5)
Disable token validation for search forms
Worked for us.
http://agaricdesign.com/note/validation-error-search-form-contact-site-a...
benjamin, Agaric Design Collective
benjamin, Agaric
Custom search by node type problem
I've spent hours trying to get this to work with no luck at all. I'm trying to create a custom search block that searches by node type just as if someone was using the Advanced Search (as described at code http://drupal.org/node/141788). When first running the code I received the Validation error as described in http://drupal.org/node/90808. To remedy I added
<input type="hidden" name="edit[form_token]" id="a-unique-id" value="<?php print drupal_get_token('search_theme_form'); ?>" />This resulted in this as my code:
The Search form works but doesn't filter by content type (content type: knowledgebase) as I'd like it to.
I'm running Drupal 5.3, any suggestions?
Much appreciated
Validation error (custom node submission html)
So I have been having some troubles with this validation error and have searched like crazy for a solution to my problem. This post seems most similar and closest to a solution to my problem, but I have not been able to get it to work. I am attempting to create a custom node submission page via html and have been receiving the "Validation error, please try again" message. Within the
in my html i have placed:
with no success. I am at a loss for answers and would really appreciate the advice! Is there a way to disable tokens for a node submission? I am using drupal 5...Thanks in advance!