majica_films
2008-07-28 13:08:47 UTC
I've spent HOURS looking for a way to stop spam through the form on my website.
I've looked at various solutions but they either cost too much money, or flat
out don't work (tutorials are great....but not when what they tell you do
doesn't match the files you've been given)
I've given up now, I'd rather take the spam than waste several more hours
trying to stop it, but, should anyone here have a quick easy solution that
won't take several hours and give me a headache, I'd really appriciate it.
Below is the code of the page the form is on (with the bits that don't matter
taken out), I'm using formmail.cgi. You can view the page here:
http://www.controlshop.co.uk/Contact/ContactForm.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The Control Shop</title>
<style type="text/css">
<!--
<script type="text/javascript">
<!--
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an
e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number
between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is
required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
} }
//-->
</script>
</head>
<form action="/cgi-bin/formmail" method="post" name="form1" id="form1"
onsubmit="MM_validateForm('Contact name','','R','Telephone','','RisNum','What
are you looking for?','','R');return document.MM_returnValue">
<input type="hidden" name="recipient" VALUE="***@controlshop.co.uk">
<label>
<div align="right"><span class="style8">*</span> - Required fields<br />
<br />
</div>
<div align="right"> <span class="style8">*</span>Contact name:
<input type="text" name="Contact name" id="Contactname" />
<br />
<br />
Company name:
<input type="text" name="Company name" id="Companyname" />
<br />
<br />
<span class="style8">*</span>Telephone:
<input type="text" name="Telephone" id="Telephone" />
<br />
<br />
Fax:
<input name="Fax" type="text" id="Fax" value="" />
<br />
<br />
E-mail:
<input type="text" name="E-mail" id="E-mail" />
<br />
<br />
<span class="style8">*</span>What are you looking for?<br />
<textarea name="What are you looking for?" id="Whatareyoulookingfor"
cols="22" rows="5"></textarea>
<br />
<br />
<input name="Send" type="submit" id="Send" value="Submit" />
<br />
<br />
<input type="reset" name="Reset" id="button" value="Reset" />
<br />
<input TYPE="hidden" NAME="redirect"
VALUE="http://www.controlshop.co.uk/thankyou.htm">
<input TYPE="hidden" NAME="return_link_url"
VALUE="http://www.controlshop.co.uk/thankyou.htm">
</div>
</label>
<p align="right"> </p>
<div align="center"></div>
</form>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1",
{imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>
I've looked at various solutions but they either cost too much money, or flat
out don't work (tutorials are great....but not when what they tell you do
doesn't match the files you've been given)
I've given up now, I'd rather take the spam than waste several more hours
trying to stop it, but, should anyone here have a quick easy solution that
won't take several hours and give me a headache, I'd really appriciate it.
Below is the code of the page the form is on (with the bits that don't matter
taken out), I'm using formmail.cgi. You can view the page here:
http://www.controlshop.co.uk/Contact/ContactForm.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The Control Shop</title>
<style type="text/css">
<!--
<script type="text/javascript">
<!--
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an
e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number
between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is
required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
} }
//-->
</script>
</head>
<form action="/cgi-bin/formmail" method="post" name="form1" id="form1"
onsubmit="MM_validateForm('Contact name','','R','Telephone','','RisNum','What
are you looking for?','','R');return document.MM_returnValue">
<input type="hidden" name="recipient" VALUE="***@controlshop.co.uk">
<label>
<div align="right"><span class="style8">*</span> - Required fields<br />
<br />
</div>
<div align="right"> <span class="style8">*</span>Contact name:
<input type="text" name="Contact name" id="Contactname" />
<br />
<br />
Company name:
<input type="text" name="Company name" id="Companyname" />
<br />
<br />
<span class="style8">*</span>Telephone:
<input type="text" name="Telephone" id="Telephone" />
<br />
<br />
Fax:
<input name="Fax" type="text" id="Fax" value="" />
<br />
<br />
E-mail:
<input type="text" name="E-mail" id="E-mail" />
<br />
<br />
<span class="style8">*</span>What are you looking for?<br />
<textarea name="What are you looking for?" id="Whatareyoulookingfor"
cols="22" rows="5"></textarea>
<br />
<br />
<input name="Send" type="submit" id="Send" value="Submit" />
<br />
<br />
<input type="reset" name="Reset" id="button" value="Reset" />
<br />
<input TYPE="hidden" NAME="redirect"
VALUE="http://www.controlshop.co.uk/thankyou.htm">
<input TYPE="hidden" NAME="return_link_url"
VALUE="http://www.controlshop.co.uk/thankyou.htm">
</div>
</label>
<p align="right"> </p>
<div align="center"></div>
</form>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1",
{imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>