php form spam protection without captcha

Protect your web form from spammer by using dynamic hash. PHP form “hash field” technique gives confirmation that server side received post data comes from sites original web form.
This “hash field” technique is simple to implement in easy two steps.

#1: Create unique dynamic hash code and add in form.

code for contact.php

<?php
function getHash()
{
    //SECRET KEY
    $uniqueKey = 'abc?#coolkey@#%';

    //GENERATE HASH(You can use many techque for unique hash)
    $hash = md5(time().rand(11111, 99999).$uniqueKey);

    return $hash;
}

$_SESSION['formOneHash'] = getHash();
?>

<form method="post" action="" name="formOne">
<input type="hidden" name="hash" value="<?php echo $_SESSION['formOneHash']; ?>"/>

<lable for="name">Name</label>
<input type="text" name="name" id="name"/>

<lable for="email">Email</label>
<input type="text" name="email" id="email"/>

<lable for="name">Message</label>
<textarea name="message" rows="4"></textarea>

<input type="submit" name="formOneSubmit" value="Contact"/>
</form>

#2: Check hash value before process web form data

code for contactHandler.php

<?php
if(isset($_POST['hash'])
&& $_POST['hash'] == $_SESSION['formOneHash'])
{
    //Process data

    //hash value work only for one time form submit
    unset($_SESSION['formOneHash']);
}
else
{
    //error message
}
?>