Solved

stop bots from submitting forms

Posted on 2006-10-24
7
787 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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

691 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