Honeypot UDT with FormBuilder – form not submitting

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
10010110
Translator
Translator
Posts: 217
Joined: Tue Jan 22, 2008 9:57 am

Honeypot UDT with FormBuilder – form not submitting

Post by 10010110 »

So, I have a UDT with the following code:

Code: Select all

if (isset($_POST['subject']) && !empty($_POST['subject'])) {
  if(isset($_POST['form_type'])) {$formtype = '('.$_POST['form_type'].')';}
  if(isset($_SERVER['REMOTE_ADDR'])) {$remote_ip = 'IP: '.$_SERVER['REMOTE_ADDR'];}
	audit('', "HOTBOT", "Bad ass spam attempt! $formtype, $remote_ip");
	exit('Sorry, the form cannot be processed like this.');
}
And in my FormBuilder template I have hard-coded this:

Code: Select all

<label>(Leave this field as is.) <input name="subject" type="text" /></label>
<input type="hidden" name="form_type" value="Contact form" />
In the “Form Submission” tab in FormBuilder admin under “User defined tag to call during form validation” I’ve selected the UDT.

The problem is now that when I enter my info (and leave the honeypot field blank, of course), it just reloads the page with all fields still filled out but doesn’t send it on submission. If I fill the honeypot field, it correctly displays the exit message. I don’t get any errors (not even in my error logs), as far as I can see. Can you spot any issue with my code?

[edit]I tried it on another site and upon form submission the form’s error message container is actually loaded but without any message in it. ??? [/edit]
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Honeypot UDT with FormBuilder – form not submitting

Post by Rolf »

- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3487
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Honeypot UDT with FormBuilder – form not submitting

Post by velden »

Of course I like Rolf's solution the best O0 but in case of the UDT I guess you should read the help. I think it expects a return value (array?).
10010110
Translator
Translator
Posts: 217
Joined: Tue Jan 22, 2008 9:57 am

Re: Honeypot UDT with FormBuilder – form not submitting

Post by 10010110 »

Thanks, Rolf. Yeah, I came across that article already but I wanted to have a universal copy/paste solution without having to add a field to every form. And this UDT solution used to work but it seemed like spammers got around it at some point and I experimented with it, thinking I found a solution but asserted just now that it doesn’t.

velden, the UDT isn’t supposed to return anything if the input is valid. It’s only supposed to exit if the honeypot field is filled out.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3487
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Honeypot UDT with FormBuilder – form not submitting

Post by velden »

10010110 wrote:velden, the UDT isn’t supposed to return anything if the input is valid. It’s only supposed to exit if the honeypot field is filled out.
Better read the help:
Validation UDT. Set this for a form, and the UDT will receive all of the form's human-readable results. The UDT should do whatever validation it wants, and return an array with the first value being true or false (indication whether the form validates), and the second value being error messages (if any).
10010110
Translator
Translator
Posts: 217
Joined: Tue Jan 22, 2008 9:57 am

Re: Honeypot UDT with FormBuilder – form not submitting

Post by 10010110 »

Thanks, velden, adding "return array(true);” appears to work. But where did you find that info? I can’t find it in https://docs.cmsmadesimple.org/tags/use ... ting-a-udt . And I also don’t see any help in the UDT admin (like the module help).
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3487
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Honeypot UDT with FormBuilder – form not submitting

Post by velden »

Ah, it has nothing to do with the UDT actually. It's the return value that FormBuilder expects. So it's in the help of FormBuilder.
10010110
Translator
Translator
Posts: 217
Joined: Tue Jan 22, 2008 9:57 am

Re: Honeypot UDT with FormBuilder – form not submitting

Post by 10010110 »

Ah, OK. Thank you very much. :)
Locked

Return to “Modules/Add-Ons”