cancel
Showing results for 
Search instead for 
Did you mean: 

Checking if a hidden field is empty or not for Contact Form

Checking if a hidden field is empty or not for Contact Form

Ok so I gave up on using reCaptcha because I couldn't figure it out, so I am trying the hidden field technique.

 

What I have done so far is:

 

form.phtml (the contact form)

 

    <label for="humans" class="humans"><?php echo Mage::helper('contacts')->__('Human Check: Leave Empty') ?></label>
    <input type="text" name="humans" id="humans" class="humans" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('humans')) ?>" value=""/>

<style type="text/css">
.humans {
display: none;
}
</style>

Module override for contacts: IndexController.php

 

$honey = $this->getRequest()->getPost('humans');

/*code that was already in the base controller*/

if($honey != '')
  {
    $error = true;
  }

What am I missing or doing wrong? I need the form to not submit when the hidden field is filled out by spam bots. I have tried several things with this and haven't come up with anything. I know the humans field is sending as I have it included with the contact form template I made previously for a subject and topic.

2 REPLIES 2

Re: Checking if a hidden field is empty or not for Contact Form

Also it doesn't appear that bots are filling out the hidden field as expected, so I really am perplexed...

Re: Checking if a hidden field is empty or not for Contact Form

So I now have it to where the bots are filling in the hidden field. Apparently they are smart enough to know if it says Humans or not. 

 

However, I still can't get it to not send when the hidden field is filled. Any help would be appreciated. Thank you