Ever since I setup my Contact Us form on a GoDaddy account, I am getting alot of spam responses with garbled nonsense information in the response form fields. I found a trick of using css to not display a form field that is initially blank. When a spam program finds the form it fills out all fields. Then when parsing the form, if the field is not blank I simply skip sending the email and goto the landing page.
Sample antispam code:
[php]
// if the url field is empty
if(isset($_POST[‘url’]) && $_POST[‘url’] == ‘’){
// then send the form to your email
mail( '[email protected]', 'Contact Form', print_r($_POST,true) );
}
[/php]
I am confused where to make the field check in the GoDaddy gdform.php code:
(and how to exit without sending the email if the field is not blank…)
[php]
<?php $request_method = $_SERVER["REQUEST_METHOD"]; if($request_method == "GET") { $query_vars = $_GET; } elseif ($request_method == "POST") { $query_vars = $_POST; } reset($query_vars); $t = date("U"); $file = $_SERVER['DOCUMENT_ROOT'] . "\ssfm\gdform_" . $t; $fp = fopen($file,"w"); while (list ($key, $val) = each ($query_vars)) { fputs($fp,"\r\n"); fputs($fp,"$val\r\n"); fputs($fp,"\r\n"); if ($key == "redirect") { $landing_page = $val; } } fclose($fp); if ($landing_page != "") { header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page"); } else { header("Location: http://".$_SERVER["HTTP_HOST"]."/"); } ?>[/php]
Any help would be greatly appreciated