-2

My contact form has been getting a ton of spam messages. My contact form has several fields. I have noticed the email address field from the spam messages always contains the strong Staceyrow and the message field always contains one or more of the following: payday, loan, loans, lender, lenders. The location field always contains the word Darussalam.

I am using a php contact form and on the back end, I am able to enter a regex for each field.

What regex do I have to enter for the email field so that if the user enters anything containing "Staceyrow" (not case sensitive) in that field, the form doesn't submit?

What regex do I have to enter for the message field so that if the user enters anything containing "payday" or "loan" or "loans" or "lender" or "lenders", (not case sensitive) in that field, the form doesn't submit?

What regex do I have to enter for the location field so if the user enters anything containing "Darussalam" (not case sensitive) the form doesn't submit?

mickmackusa
  • 43,625
  • 12
  • 83
  • 136
  • why not add a CAPTCHA ? –  Jun 13 '17 at 05:37
  • You might be interested in this question: [How to prevent robots from automatically filling up a form?](https://stackoverflow.com/questions/2387496/how-to-prevent-robots-from-automatically-filling-up-a-form) – Gras Double Jun 13 '17 at 05:38

1 Answers1

2

Match "Staceyrow" with /staceyrow/i

Match "payday", "loan", "loans", "lender", or "lenders" with /(?:loans?|payday|lenders?)/i (*just be careful about matching innocent message field values)

Match "Darussalam" with /darussalam/i

If you use these criteria to deny form submission and/or provide specific feedback about the denial, the bot designers will be able to easily adjust their spamming values without submitting.

Perhaps make some kind of rule where the form always "seems" to submit, but there is either a generalized "something went wrong" error message, or no error message at all and the submission gets dumped in an inactive database table, where you can scan it manually to make sure that no innocent users have been caught in your screen.

Or perhaps you could allow the suspicious users to submit, but just have an extra column in your database table that marks the user as "suspicious". The suspicious users can have very limited privileges until human eyes make some sort of decision.

As asterisked earlier, "slender" will raise a flag in the message field because. For this reason, the message field is the least reliable for identifying the bad apples. Oh, and if you plan to expand your message pattern, put the shortest strings in the earlier alternatives and longer strings toward the back for performance reasons.

mickmackusa
  • 43,625
  • 12
  • 83
  • 136