PHP 隐形验证码
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 隐形验证码相关的知识,希望对你有一定的参考价值。
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; }
以上是关于PHP 隐形验证码的主要内容,如果未能解决你的问题,请参考以下文章
javascript ajax提交隐形验证码
如何将 Firebase 隐形 reCAPTCHA 用于 Angular Web 应用程序?
PHP生成各种验证码和Ajax验证
php的图片验证码代码
php中如何刷新验证码
如何用PHP生成验证码