/ Published in: PHP
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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
HTML: <div class="hidebox"> Please leave blank: <input type="text" id="gotcha" tabindex="-1" name="gotcha" /> </div> PHP: <?php if($_POST["gotcha"]!=""){ } ?> 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; }
URL: http://www.bensky.co.uk/blog/code-tutorials/invisible-capcha-concept-stop-spam-email/