PHP表单-带有验证蜜罐 [英] PHP form - with validation honeypot

查看:113
本文介绍了PHP表单-带有验证蜜罐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在以下方面能正常工作,但对垃圾邮件机器人开放. 我想放入蜜罐,而不是验证码. 以下代码可用于验证名称,电子邮件,消息, 但我无法使其与蜜罐配合使用.

I have the below for that works well, but is open for spam bots. I want to put in a honeypot, not a captcha. The code below works with the validation for the name, email, message, but I can not get it to work with the honeypot.

任何人都可以看一下"honeypot"代码并告诉我如何解决吗?

Can anyone look at the "honeypot" code and tell me how to fix it?

我希望表单提供一个$ success2 =不允许发送垃圾邮件",其作用类似于表单已提交,但实际上并未提交.

I would like for the form to give an $success2 = "No Spamming allowed" that acts like the form was submitted, but does not actually submit the form.

谢谢

表格:

<form id="contactform" action="send2.php" method="post"><div id="success"></div><div id="error"></div>
<label for="name">Name:</label><input type="text" id="name" name="name"/>
<label for="email">Email:</label><input type="text" id="email" name="email"/>
<label for="message">Message:</label><textarea id="message" name="message" rows="12" cols="20"></textarea>
<label id="robot">Are you a robot?</label><input type="text" name="robot" id="robot"> 
<input type="submit" value="Send your message" id="send" />
</form>

PHP: 可以在这里找到: http://goviewmy.com/contact/showcode/

The PHP: can be found here: http://goviewmy.com/contact/showcode/

对不起,但是我无法在此问题中发布PHP代码,因此我附上了链接.

Sorry, but i cannot get the PHP code to post in this question, so I attached a link to it.

谢谢

推荐答案

如果蜜罐具有听起来合法的字段名称,它们的工作效果最佳,也应使用javascript将其隐藏,以在页面加载后更改CSS. (大多数)漫游器未启用javascript,因此它们无法处理不应填写此字段的内容.

Honeypots work best if they have a field name that sounds legit, they should also be hidden using javascript to change the css after the page loads. (Most) bots don't have javascript enabled so they cannot process that this field should not be filled out.

我使用类似这样的东西:

I use something like this:

<div class='req'>
    <label for='website'>Leave blank</label>
    <input type='text' name='website'>
</div>

用jquery隐藏它:

Hide it with jquery:

$(document).ready(function(){
    $(".req").hide();
});

如果该字段中填写的是这样的内容,请拒绝它在服务器端

reject it server side if the field is filled out with something like this

if($_POST['website'] != ''){
    echo "It appears you are a bot!";
}
else{
//process the rest of the form
}

这篇关于PHP表单-带有验证蜜罐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆