# Form Security - Spam Bots

**URL:** <https://www.phphelp.com/t/form-security-spam-bots/25347>\
**Category:** Beginners - Learning PHP\
**Created:** [July 15, 2016, 11:00am UTC](https://www.phphelp.com/t/form-security-spam-bots/25347 "2016-07-15T11:00:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@Andy](https://www.phphelp.com/u/Andy)\
**Post date:** [July 15, 2016, 11:00am UTC](https://www.phphelp.com/t/form-security-spam-bots/25347/1 "2016-07-15T11:00:12Z")

</div>

Hi everyone,

I have a form that asks for a users name, email & any comments.  
I have included a “Are you Human” question i.e. 5 + 2 =

Name is set to input type “text”.  
Email is input type “email”.  
Comment is input type “text”.  
Are you Human is currently not set but it could be set to number and a range of 1 - 10 for example.

What is 5+2?\<input name=“human” type=“number” min=“1” max=“10”\>

My Question relates to spam bots. How intelligent are they these days?

If I set the “Are you Human” input type to number and a range, am I making it extra easy for the spam bot?  
Can they process the information I have provided?

If I don’t narrow down the type and range, a human will still understand the question.  
However, would it be more difficult for the spam bot?  
Would they fill the field with text or something else for example?

BTW, I have included both client and server-side validation for this question field.

Thanks for any help / insights.

Andy 😉

---

<div class="post-metadata">

**Author:** ![ErnieAlex](https://www.phphelp.com/letter_avatar_proxy/v4/letter/e/bc8723/32.png) [@ErnieAlex](https://www.phphelp.com/u/ErnieAlex)\
**Post date:** [July 15, 2016, 12:37pm UTC](https://www.phphelp.com/t/form-security-spam-bots/25347/2 "2016-07-15T12:37:55Z")

</div>

Well, you are using HTML5 input types. They only work under a browser that works with HTML5. (Not all browsers are up  
to date!) It is the currently standard in the world, but, older systems might have problems with the input types.

A spam-bot is only as good as it’s programmer. It is extremely easy for a spammer to read your page of HTML code and  
know what it does. Any PHP programmer can load any URL from the internet and save it as a string and decode it’s inner  
HTML to see what is in the INPUT field. BUT, most spammers do not sit and look at the millions of pages that their code  
has scraped off the internet. Therefore, it is good for a start to just use your simple 5+2 system. If your site starts having  
spamming issues, then, you would have to move up to a “Captcha” type of system where the picture is harder for the spam  
system to decode. Basically, a spammer would have to program his robot to handle inputs with every caption that you could  
dream up. “Are you Human?” is a common one, but, the spammer would need to customize the code to look for that. Doubt  
that they would go that far. A spamming robot is only as smart as it’s programmer designed it to be. They do not do any  
other thing except what they are designed to do. One simple change can make it not work.

Now, as far as your server-side and client-side validation? If you place code in Javascript into your HTML, you have to be  
careful that it does not give away your security. Remember that Javascript can be seen by a spammer if it is embedded  
into your HTML code. You can always review this by just RIGHT-CLICKING on your live page and selecting VIEW-SOURCE.  
Then, you can look at the input fields and see what the spammer’s robot sees. (Note that you will never see any PHP code  
in the listing!)

Not sure if this helps, but, hopefully it does… Good luck!

---

<div class="post-metadata">

**Author:** ![Andy](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@Andy](https://www.phphelp.com/u/Andy)\
**Post date:** [July 15, 2016, 2:40pm UTC](https://www.phphelp.com/t/form-security-spam-bots/25347/3 "2016-07-15T14:40:35Z")

</div>

Yip, that helps ErnieAlex. Thanks for the information.  
As you say, it should do as a start. I can always revisit if there are any issues in the future - you’ve gotta start somewhere!

Thanks again.

Andy 😉

---

<div class="post-metadata">

**Author:** ![ErnieAlex](https://www.phphelp.com/letter_avatar_proxy/v4/letter/e/bc8723/32.png) [@ErnieAlex](https://www.phphelp.com/u/ErnieAlex)\
**Post date:** [July 15, 2016, 2:49pm UTC](https://www.phphelp.com/t/form-security-spam-bots/25347/4 "2016-07-15T14:49:34Z")

</div>

You are very welcome… I will mark this one solved even if it is a bit hanging open. Then, when you get further we can deal  
with other questions on the same subject…

Good luck! CYA in the Bitstream… ( That’s all this really is, LOL )

---

<div class="post-metadata">

**Author:** ![astonecipher](https://www.phphelp.com/user_avatar/www.phphelp.com/astonecipher/32/2797_2.png) [@astonecipher](https://www.phphelp.com/u/astonecipher)\
**Post date:** [July 15, 2016, 5:45pm UTC](https://www.phphelp.com/t/form-security-spam-bots/25347/5 "2016-07-15T17:45:15Z")

</div>

One of the best simple validations I have seen, asked for an artist album name. Something I had to lookup to use their site. Takes simple validation to another level.

---

<div class="post-metadata">

**Author:** ![ErnieAlex](https://www.phphelp.com/letter_avatar_proxy/v4/letter/e/bc8723/32.png) [@ErnieAlex](https://www.phphelp.com/u/ErnieAlex)\
**Post date:** [July 15, 2016, 6:43pm UTC](https://www.phphelp.com/t/form-security-spam-bots/25347/6 "2016-07-15T18:43:26Z")

</div>

Yes, nice variation! I have used the “You must erase this line!” in an extra field. Since web-bots tend to fill in every field, this  
works in a simple way, too…

---

<div class="post-metadata">

**Author:** ![Andy](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@Andy](https://www.phphelp.com/u/Andy)\
**Post date:** [July 16, 2016, 8:15pm UTC](https://www.phphelp.com/t/form-security-spam-bots/25347/7 "2016-07-16T20:15:54Z")

</div>

Both sound like really good ideas.

---

<div class="post-metadata">

**Author:** ![Strider64](https://www.phphelp.com/user_avatar/www.phphelp.com/strider64/32/3161_2.png) [@Strider64](https://www.phphelp.com/u/Strider64)\
**Post date:** [July 18, 2016, 6:43pm UTC](https://www.phphelp.com/t/form-security-spam-bots/25347/8 "2016-07-18T18:43:25Z")

</div>

I found the Honeypot Technique ([http://www.dexmedia.com/blog/honeypot-technique/](http://www.dexmedia.com/blog/honeypot-technique/)) to be pretty effective against spam bots in general. The added bonus it doesn’t distract real users from accessing the site, but nothing is 100 percent foolproof.

---

<div class="post-metadata">

**Author:** ![ErnieAlex](https://www.phphelp.com/letter_avatar_proxy/v4/letter/e/bc8723/32.png) [@ErnieAlex](https://www.phphelp.com/u/ErnieAlex)\
**Post date:** [July 18, 2016, 8:59pm UTC](https://www.phphelp.com/t/form-security-spam-bots/25347/9 "2016-07-18T20:59:38Z")

</div>

I had to read it twice to get it… It is basically like removing text, but, is hidden instead. So, this would work well.  
Unless the bot skipped filling that field in… I agree this is a nice non-distracting version…
