Solved

stop bots from submitting forms

Posted on 2006-10-24
7
780 Views
Last Modified: 2012-06-22
some bots have found my site which accepts a form from users for posting of classified ads.  Now I get at least 1 every five minutes from adamn bot.

How do I prevent this?
0
Comment
Question by:alivemedia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 8

Expert Comment

by:Rytmis
ID: 17796363
For a site of mine we implemented a fairly simple solution.

We had two fields, name and message, so we introduced two new fields with mangled names, and use those instead. We use CSS to hide the old fields, and just in case CSS is disabled, both hidden fields have labels saying "please do not fill this field" next to them.

Every time a comment is posted, we check if either of the hidden fields have text in them. If they do, we mark the message as spam. Messages marked as spam are not displayed.

Every now and then I manually clean up the accumulated spam messages, but the end users don't see any of it any more.
0
 
LVL 2

Author Comment

by:alivemedia
ID: 17796506
I guess this assumes that the bots don't use css or have it disabled?
0
 
LVL 17

Expert Comment

by:akshah123
ID: 17796530
There are two solutions.

1. Use image with text in it for verification similar to what yahoo and hotmail does while signing up.  
http://www.finalwebsites.com/snippets.php?id=39
or
http://www.phpclasses.org/browse/package/1569.html

2. Usually, these bots leave a message that has a certain pattern to it.  Such as they will always have <a href="somelink">somelink</a>[url]somelink[/url]

If so, you can update the script that processes the form submission to look for this pattern using some regular expression.  If it matches that regular expression, you can mark it as spam.  However, this is risky as you may get a false positive from time to time.  

The best solution is of course to use the CAPTCHA logic where user has to provide text that matches a randomly generated image as show in above link.  This method is used by big sites that have a great deal of hits from all kinds of bots.

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:Rytmis
ID: 17796544
Well basically the bot can't tell *why* the field is hidden (lots of ajaxy things keep stuff hidden via CSS rules). Anyways I'm not saying this is the be-all end-all solution, but 100% of the spam we've been getting has been caught in it.

I'm thinking that if this filtering stops being effective at some point, I'll probably start changing the field name on every page load. I'm pretty sure that the bots don't load the page as often as they post to it.
0
 
LVL 16

Expert Comment

by:HackneyCab
ID: 17799385
If you're sure that the bot is not loading the page before submitting, add a session variable to the form page. If this session variable is not set when the form processor script is reached, send a thank you message as though you're happy with their rubbish, but silently discard the submission. No legitimate user should be posting to your processor script without using your form first.
0
 
LVL 2

Accepted Solution

by:
_delas earned 500 total points
ID: 17942092
try some logical questions, like http://it.php.net/manual/add-note.php?sect=function.fopen&redirect=http://it.php.net/manual/it/function.fopen.php
or try populating an hidden field with javascript... it seems that bots haven't js iterpreter
0
 
LVL 8

Expert Comment

by:Rytmis
ID: 17942155
As a curiosity: during the last two weeks our simplistic filtering has stop some ~400 spam comments (and amazingly, not a single one has yet come through). YMMV though.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question