1

我对 PHP 完全陌生,我只是想在我的表单中阻止垃圾邮件。我已经想出了如何使用以下代码来做一个蜜罐(url 字段),它可以阻止 90% 的垃圾邮件——但是这个令人讨厌的电子邮件发送者通过了(我们称之为他们redacted@example.com)。我想在我的表单中写一行代码,它只是说如果电子邮件字段填写了 text 'redacted@example.com',那么不要通过表单。有没有人可以帮我做到这一点?

// if the url field is empty
// if(isset($_POST['url']) && $_POST['url'] == ''){

// then send the form to your email
// mail( 'myemail@me.com', 'Contact Form', print_r($_POST,true) );
// }

// otherwise, let the spammer think that they got their message through
4

1 回答 1

1

使用此代码

if(isset($_POST['url']) && $_POST['url'] == '') {
    if ($_POST['email'] != 'dukang2004@yahoo.com') {
        // then send the form to your email
         mail( 'myemail@me.com', 'Contact Form', print_r($_POST,true) );
    }
}
于 2012-11-20T05:52:17.623 回答