i am using vtiger and recieveing alot of spam on the website contact page i am using this code
Add an extra field to the form that you do not use. Hide it with css.
Spam bots visiting the page will fill all fields, even if they are not shown.
If there's something in the hidden field, the whole form is spam, and you can discard the data.
I would recommend You other antiSpam method - with token/private key.
In HTML form You put this:
<form action="..." method="post">
<?php
$publicKey = rand()%9;
$privateKey = 0.9;
$token = sha1( $publicKey * $privateKey + $privateKey );
?>
<input type="hidden" name="publicKey" value="<?php echo $publicKey; ?>" />
<input type="hidden" name="token" value="<?php echo $token; ?>" />
</form>
And add also few lines of code before IF condition - for example: fragment with SQL query or send mail, just to check/validate sended token by POST method:
<?php
$publicKey = $_POST['publicKey'];
$privateKey = 0.9;
$token = sha1( $publicKey * $privateKey + $privateKey );
if ( $token == $_POST['token'] ) {
// do something, eg: SQL query, send mail
}
?>
AND REMEMBER! Always validate and sanitize all Your input data! :)