[英]PHP form - with validation honeypot
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. 下面的代码适用于名称,电子邮件,消息的验证,但我无法使用蜜罐。
Can anyone look at the "honeypot" code and tell me how to fix it? 任何人都可以看看“蜜罐”代码并告诉我如何解决它?
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. 我希望表单能够提供$ success2 =“不允许垃圾邮件”,其行为类似于提交表单,但实际上并未提交表单。
Thanks 谢谢
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>
The PHP: can be found here: http://goviewmy.com/contact/showcode/ PHP:可以在这里找到: http : //goviewmy.com/contact/showcode/
Sorry, but i cannot get the PHP code to post in this question, so I attached a link to it. 抱歉,我无法在此问题中发布PHP代码,因此我附上了一个链接。
Thanks 谢谢
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. 如果Honeypots的字段名称听起来合法,那么它们的效果最好,它们也应该在页面加载后使用javascript隐藏以更改css。 (Most) bots don't have javascript enabled so they cannot process that this field should not be filled out. (大多数)机器人没有启用JavaScript,所以他们无法处理不应该填写此字段。
I use something like this: 我使用这样的东西:
<div class='req'>
<label for='website'>Leave blank</label>
<input type='text' name='website'>
</div>
Hide it with jquery: 用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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.