php - HTML - 如何在我的spambot蜜罐中执行PHP

130 0

我想在网站上放一个蜜罐来阻止垃圾邮件。

我发现这个答案很有用,在页面上包含一个不可见的复选框:


<input


 type="checkbox"


 name="contact_me_by_fax_only"


 value="1"


 style="display:none !important"


 tabindex="-1"


 autocomplete="off"


>



然后,PHP测试复选框是否已选中:


$honeypot = FALSE;


if (!empty($_REQUEST['contact_me_by_fax_only']) && (bool) 


$_REQUEST['contact_me_by_fax_only'] == TRUE) {


 $honeypot = TRUE;


 log_spambot($_REQUEST);


 # treat as spambot


} else {


 # process as normal


}



我以前没有用过多少PHP ,我的问题:

  • 我可以把这个PHP放在我的html代码中,周围有<?php?>标签?
  • 如果是这样,那么我把PHP放在哪里? 是否必须在表单之后?
  • 在PHP中说#process正常的部分中,我是否需要在此处放置内容?
  • 还是我应该把PHP放在我的post.php文件中,提交表单?

我的html代码的组成部分如下:


<form action="post.php" method="post">


 </br>


 <label for="email"></label>


 <input type="email" placeholder="Enter your email address..."


 name="email" required>


 <button type="submit" class="signupbtn">Sign Up</button>


 <input type="checkbox" name="contact_me_by_fax_only"


 value="1" style="display:none !important" tabindex="-1" autocomplete="off">


</form>



时间: 原作者:

77 1

更好的蜜罐实现(表单反垃圾邮件)

我将添加一些例子HTML来解释它,


$honeypot = FALSE;


if (!empty($_REQUEST['contact_me_by_fax_only']) && (bool) 


$_REQUEST['contact_me_by_fax_only'] == TRUE) {


 $honeypot = TRUE;


 log_spambot($_REQUEST);


 // treat as spambot -- here we will place the HTML"inline"


?>


<html>


<body>


<p>Tasty spam, thanks!</p>


</body>


</html>



<?php


 exit(); // all done if a spambot



} else {


 // process as normal -- here we will use a function, note that in PHP


 // scope rules will hide most global variables from the function!


 process_human_response();


}



function process_human_response()


{


 //... get data from $_REQUEST


 //... process data



?>


<html>


<body>


<p>Thank you good human!</p>


</body>


</html> 



原作者:
...