I am totally new to PHP and I am just trying to block spam in my forms. I have
figured out how to do a honeypot (url field) with the following code that
blocks 90% of the spam - but this one irritating emailer gets through
(let's call them redacted@example.com
). I would like to write one line of
code in my form that just says if the email field is filled out with the text
'redacted@example.com'
, then don't pass the form through. Is there anyone who can help me do this?
// 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
Use this code
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) );
}
}