Page 1 of 1

PHP Fatal error: Uncaught Exception: Spam detected.

Posted: Tue Mar 25, 2025 6:43 pm
by gofrank
I have a client with a contact form set to use a "honeypot" to eliminate spam. The "honeypot" field is "address". When a bot fills in the "address" field, an exception is thrown (as designed). However, this generates the following entry in the site's error_log:

Code: Select all

[25-Mar-2025 12:42:06 UTC] PHP Fatal error:  Uncaught Exception: Spam detected.
<br> in /home/mysite/public_html/contact-the-crew.php:21
Stack trace:
#0 {main}
  thrown in /home/mysite/public_html/contact-the-crew.php on line 21
  
Looking at the WB-generated php code on the specified lines, I see:

Code: Select all

17   $internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha",          "recaptcha_challenge_field", "recaptcha_response_field", "g-recaptcha-response", "h-          captcha-response", "address");
18   if (!empty($_POST['address']))
19   {
20      $error .= "Spam detected.\n<br>";
21      throw new Exception($error);
22   }
Is it normal for the "Spam detected" honeypot code to generate a fatal error entry in error_log? This does not happen when an exception is thrown for an invalid email address.

Re: PHP Fatal error: Uncaught Exception: Spam detected.

Posted: Tue Mar 25, 2025 8:42 pm
by Pablo
In this context, I do not see anything wrong in the code.
To say something meaningful about this I need to see the full code.

Re: PHP Fatal error: Uncaught Exception: Spam detected.

Posted: Wed Mar 26, 2025 11:16 am
by gofrank
Your wish is my command: full code

Re: PHP Fatal error: Uncaught Exception: Spam detected.

Posted: Wed Mar 26, 2025 12:33 pm
by Pablo
Thanks, I will investigate if this can be improved.