Return to Snippet

Revision: 28450
at April 2, 2012 14:06 by hotdiggity


Updated Code
HTML:
<div class="hidebox">
Please leave blank: <input type="text" id="gotcha" tabindex="-1" name="gotcha" />
</div>

PHP:
<?php
if($_POST["gotcha"]!=""){
header("Location: {$_SERVER[HTTP_REFERER]}");exit;
}
?>

CSS:
.hidebox {
    position:absolute;
    background-color:#CC0000;
    left:0px;
    top:-500px;
    width:1px;
    height:1px;
    overflow:hidden;
}

Note for WordPress:
/wp-content/themes/theme-name/comment.php
add around line 65 (after author,email,url inputs):
<!--Catch sp@m-->
<p class="hidefield"><input type="text" name="gotcha" id="gotcha" size="22" tabindex="-1" />
<label for="gotcha"><small><?php _e('Leave blank!'); ?></small></label>
</p>

/wp-comments-post.php
Add after approx. line 54:
$comment_gotcha       = ( isset($_POST['gotcha']) ) ? trim($_POST['gotcha']) : null;

Add after approx. line 87:
if ( $comment_gotcha != '' ) die( __('Error: Your post has been rejected as spam') );	

i.e., after 

if ( '' == $comment_content )
	wp_die( __('Error: please type a comment.') );

/wp-content/themes/theme-name/style.css
.hidefield { position:absolute; background-color:#CC0000; left:0px; top:-500px; width:1px; height:1px; overflow:hidden; }

Revision: 28449
at July 8, 2010 11:29 by hotdiggity


Updated Code
HTML:
<div class="hidebox">
Please leave blank: <input type="text" id="gotcha" tabindex="-1" name="gotcha" />
</div>

PHP:
<?php
if($_POST["gotcha"]!=""){
header("Location: {$_SERVER[HTTP_REFERER]}");exit;
}
?>

CSS:
.hidebox {
    position:absolute;
    background-color:#CC0000;
    left:0px;
    top:-500px;
    width:1px;
    height:1px;
    overflow:hidden;
}

Revision: 28448
at July 8, 2010 11:25 by hotdiggity


Initial Code
HTML:
<div class="hidebox">
Please leave blank: <input type="text" id="gotcha" tabindex="-1" name="gotcha" />
</div>

PHP:
<?php
if($_POST["gotcha"]!=""){
header("Location: {$_SERVER[HTTP_REFERER]}");exit;
}
?>

CSS:
input#gotcha {
    position:absolute;
    background-color:#CC0000;
    left:0px;
    top:-500px;
    width:1px;
    height:1px;
    overflow:hidden;
}

Initial URL
http://www.bensky.co.uk/blog/code-tutorials/invisible-capcha-concept-stop-spam-email/

Initial Description
Create a textbox that the bot will presume is just a field it can exploit with rubbish and label it with an indicator to let any viewers without the privileges of CSS know that it is to be left blank.

Initial Title
Invisible Captcha

Initial Tags


Initial Language
PHP