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: * |
|
<?php echo($viesti) ?>
Nimi: * | |
Yritys: * | |
Puh/Email: * | |