user3894741
user3894741

Reputation: 27

using hidden form field to reduce spam

In an effort to reduce spam i have a form with a value 'email2' that's hidden in CSS.

and then in my php processing form thing ive got this:

if(!empty($_POST['email2'])) 
{ die ("Sorry I believe you are a robot, please try again 
        and if you aren't... only enter your email once");
}
else {
submit data to mysql
} 

The principle is that if the email2 form is left blank, which will happen with a human using css, the form will be processed. And then if it is filled by a bot filling everything in site then it will not be processed. And this is actually working BUT...

i dont understand how its working and i feel incredibly stupid. Correct me if i am wrong but looking at the code above it says if the email2 box is empty then the form is not processed. But in actuality it processes it if it's filled.

I am a mightily confused php amateur

Upvotes: 0

Views: 77

Answers (1)

Quentin
Quentin

Reputation: 943615

! is the not operator.

So it says if not empty.

Upvotes: 1

Related Questions