Need help with spam protection on contact form

Hi!

I’d appreciate any help with the code below. I need to apply a spam protection on it. I found the simple load time based code but haven’t been able to get it working. I think the problem is with the location of the code.
Thanks!

This is the code I would want to use in it:

<input type="hidden" name="loadtime" value="time();" />

and

[php]
$totaltime = time() - $loadtime;

if($totaltime < 7) {
echo(“Please fill in the form before submitting!”);
exit;
}[/php]

And this is the contact form it should be applied in:

[code]

body { font: 11px/170% Georgia, serif; color: #494949; } table { font: 11px/170% Georgia, serif; color: #494949; } input, select, textarea { font-family: Georgia, serif; font-size: 11px; } <?php $nimi = $_POST['nimi']; $yritys = $_POST['yritys']; $puh = $_POST['puh']; $aihe = $_POST['aihe']; $viesti = $_POST['viesti']; $lah = $_POST['lah']; $error = 0; $eiprint = 0; if ($lah == "lah") { if (($nimi == "") or ($nimi == " ")) { $v1 = "#ff0000"; $error = 1; } else { $v1 = "#000000"; } if (($yritys == "") or ($yritys == " ")) { $v2 = "#ff0000"; $error = 1; } else { $v2 = "#000000"; } if (($puh == "") or ($puh == " ")) { $v3 = "#ff0000"; $error = 1; } else { $v3 = "#000000"; } if (($aihe == "") or ($aihe == " ")) { $v5 = "#ff0000"; $error = 1; } else { $v5 = "#000000"; } if (($viesti == "") or ($viesti == " ")) { $v6 = "#ff0000"; $error = 1; } else { $v6 = "#000000"; } if ($error == 1) echo('Kaikki kohdat ovat pakollisia.
'); if ($error == 0) { $eiprint = 1; $email_subject = "Yhteydenotto kotisivuilta"; $email_to = "[email protected]"; $email_message .= "Nimi: ".$nimi."\n"; $email_message .= "Yritys: ".$yritys."\n"; $email_message .= "Puh/email: ".$puh."\n"; $email_message .= "Aihe: ".$aihe."\n"; $email_message .= "Viesti: ".$viesti."\n";

echo(‘Kiitoksia yhteydenotostanne. Vastaamme teille mahdollisimman pikaisesti.’);
// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
‘X-Mailer: PHP/’ . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
}
} else
{
$v1 = “#000000”;
$v2 = “#000000”;
$v3 = “#000000”;
$v4 = “#000000”;
$v5 = “#000000”;
$v6 = “#000000”;
}
if ($eiprint == 0)
{
?>

Aihe: *
/>Tarjouspyyntö
/>Muu
Viesti (2000 merkkiä): *
<?php echo($viesti) ?>
Nimi: *
Yritys: *
Puh/Email: *
<?php } ?> [/code]

what is 7 supposed to represent? i know some fast typers, but none can do it in less than 7 miliseconds. php deals with time in miliseconds. So if you want to take 7 seconds off, then you need to representat that as 7000.

You’re better off using human verification. create a table with questions and answers that only a human would know, like 3 + 5.

Sponsor our Newsletter | Privacy Policy | Terms of Service