解决方法
Bots与阅读CSS或
JavaScript一样,至少现在.
<form method="post" action="send.PHP"> <ol> <li> <label for="name">Name</label> <input type="text" name="name" value=""> </li> <li> <label for="email">Email</label> <input type="text" name="email"> </li> <!-- We hide this with CSS,that's why it has an ID. --> <li id="user"> <label for="username">Username</label> <input type="text" name="username"> </li> <!-- //end --> <li> <input type="submit" name="submit" value="Send It!"> </li> </ol> </form>
您可以看到用户名字段将被隐藏.机器人无法识别这个.
您之后需要做的只是验证该字段在您的后端代码是空的.
<?PHP if( !isset($_POST['name'])) { die("No Direct Access"); } // Make sure the form has actually been submitted $name = $_POST['name']; $email = $_POST['email']; $spam = $_POST['username']; // Bot trap if($spam) { // If the hidden field is not empty,it's a bot die("No spamming allowed bitch!"); } else { // Process the form like normal }
使用模块BOTCHA Spam Prevention可以更容易地完成上述过程
此外,您可以看看这些文章,以获得更好的整体观点.
Green-beast和web design,但是您也可以在网络上找到像这样的几十个文章