Share/Bookmark

Featured Posts

SharePoint Ticker Web Part from Existing Data Ever wanted to create a ticker in SharePoint without having to buy the $99 add-on from Microsoft, well here's the code: Simply create a new Web Part using the 'Content Editor' and open the 'Source Editor...'...

Read more

Sony E3 Prediction 2010 With E3 upon us in the coming weeks, and Sony keeping tight lipped about their schedule I think it's time we started predicting the outcome, the announcements and surprises with educated and industry sector...

Read more

Sony E3 Prediction 2010 With E3 upon us in the coming weeks, and Sony keeping tight lipped about their schedule I think it's time we started predicting the outcome, the announcements and surprises with educated and industry sector...

Read more

Whats next for Nintendo? Today I noticed that Nintendo have had falling profits for 2010 and predict even less sales for next year. The Wii 2 hasn`t been officially announced and from what I can see is not really on the radar....

Read more

7 Great Free Android Apps The Android mobile operating system is both fast, reliable and can do everything that the Apple OS can and a little more (all for normally a fraction of the price.) plus it supports Flash and soon Flash...

Read more

Stop Most Robots Posting to your Forms

Posted by matthew | Posted in Code Snippets, Tutorial | Posted on 05-03-2010

Tags: , , ,

6

Sometimes you don’t want to use captchas or “are you human questions” on your forms, well here’s a simply way to block the vast majority of bots posting to your website forms.

This quick technique is easy to implement and relies on that fact that bots are stupid and pick up on keywords and try to complete all the fields in a form.

The best way to stop bots is to always use a combination of techniques, such as captchas and IP address checking, but this method will help eliminate a lot of junk.

On your form simply include a hidden text field called something generic like “email” if you have an email field call it something obscure like “customcontact” eg:

<form method="post" action="/form">
<input type="text" name="customcontact" />
<input type="hidden" name="email" />
<input type="submit" value="GO" />
</form>

The bot will see the hidden email field and try to populate it. On you form validation, check to see if this field is empty:


if(empty($_POST['email'])) {
// you are a human
} else {
// you are a robot
}

If the field has something in it, a bot has made the submission so discard it.

If you find that this still doesn’t work try using CSS instead:

<form method="post" action="/form">
<input type="text" name="customcontact" />
<input type="text" name="email" style="display:none;"/>
<input type="submit" value="GO" />
</form>

The bot will see the field and try to populate it as it ignores CSS styles, an actual user won’t see the field so won’t be able to add anything to it.

This is not a fail-safe way to stop bots submitting your form, but will help reduce a number of rudimentary bot attacks on your forms.

Comments (6)

[...] the rest here:  Cardboard Coder » Blog Archive » Stop Most Robots Posting to your … Posted in Object. Tags: article, cardboard-coder, database, delicious, facebook, featured-posts, [...]

Hello. And Bye.lol

Hello
good reads, i’ve subscribed to your feed hope to see some more code snippets in VB.net, do you guys deal with doing updates to pc on mass with vb also, like boot up settings?

Hi
I am a newbie here.
Glad to find this forum…as what I am looking for

Very nice site!

Very nice site!

Write a comment