Morning All!
So, we have a formit call, form and are using the math validator snippet posted from the forum here, but spam is still getting through and I dont know how / why, i've checked and double checked my form and calls but still no luck. chances are its something glaringly obvious but we have a client who is constantly being bombarded with spam thus the use of the validator.
FORM:
<div class="fastq">
<div class="fastqtop"></div>
<div class="fastqtitle">
<div class="fastq-title">[[*introtext]]</div>
</div>
<div class="fastqform">
<form action="[[~[[*id]]]]" method="post" class="fast-question" name="fast-question">
<input type="hidden" name="workemail:blank" value="" />
<input type="hidden" name="pagetitle" value="[[*pagetitle]]" />
<input type="hidden" name="sample" value="[[date]]" />
<input type="hidden" name="subdate" id subdate" value="[[date]]" >
<ul class="fastqleft">
<li class="fastq-sal">
<select name="fastq_sal" value="[[!+fi.fastq_sal]]" id="fastq_sal">
<option value="">Title</option>
<option value="Mr" [[!+fi.fastq_sal:FormItIsSelected=`Mr`]]>Mr</option>
<option value="Miss" [[!+fi.fastq_sal:FormItIsSelected=`Miss`]]>Miss</option>
<option value="Mrs" [[!+fi.fastq_sal:FormItIsSelected=`Mrs`]]>Mrs</option>
<option value="Ms" [[!+fi.fastq_sal:FormItIsSelected=`Ms`]]>Ms</option>
<option value="Dr" [[!+fi.fastq_sal:FormItIsSelected=`Dr`]]>Dr</option>
</select>
<span class="error"> [[!+fi.error.fastq_sal]]</span> </li>
<li class="fastq-name">
<input type="text" name="fastq_name" id="fastq_name" onfocus="if(this.value == 'Forename: [[!fi.fastq_name]]') { this.value = ''; }" value="Forename: [[!fi.fastq_name]]" />
<span class="error"> [[!+fi.error.fastq_name]]</span> </li>
<li class="fastq-surname">
<input type="text" name="fastq_surname" id="fastq_surname" onFocus="if(this.value == 'Surname: [[!fi.fastq_surname]]') { this.value = ''; }" value="Surname: [[!fi.fastq_surname]]" />
<span class="error"> [[!+fi.error.fastq_surname]]</span> </li>
<li class="fastq-email">
<input type="text" name="fastq_email" id="fastq_email" onFocus="if(this.value == 'Email: [[!fi.fastq_email]]') { this.value = ''; }" value="Email: [[!fi.fastq_email]]" />
<span class="error" > [[!+fi.error.fastq_email]]</span> </li>
<li class="fastq-email">
<input type="text" name="fastq_contact" id="fastq_contact" onFocus="if(this.value == 'Preferred Contact Number:') { this.value = ''; }" value="Preferred Contact Number:" />
</li>
</ul>
<ul class="fastqright">
<li class="fastq-text">
<textarea name="fastq_text" id="fastq_text">Tell us about your current situation; whether you have a claim already or are thinking of making a claim. [[!+fi.fastq_text]]</textarea>
<span class="error">[[!+fi.error.fastq_text]]</span> </li>
<li><span style="font-size:12px; padding-lefT:20px;">What is [[!+fi.op1]] [[!+fi.operator:is=`-`:then=`-`:else=`+`]] [[!+fi.op2]]?<span class="error">[[!+fi.error.math]]</span></span>
<input type="hidden" name="op1" value="[[!+fi.op1]]" />
<input type="hidden" name="op2" value="[[!+fi.op2]]" />
<input type="hidden" name="operator" value="[[!+fi.operator]]" />
<input type="text" name="math" value="[[!+fi.math]]" />
<br/>
<span style="font-size:10px;">This ensures that you are a person, not an automated program, submitting this form. This field is required. </span></li>
<li class="fastq-submit">
<input type="submit" width="183" height="21" value="Submit" name="fastqsub" id="fastqsub" onClick="_gaq.push(['_trackEvent', 'Contact', 'Submit Contact Form', 'Page – [[*pagetitle]]']);"/>
</li>
</ul>
</form>
<div style="clear:both;"></div>
</div>
</div>
Formit Call:
[[!FormIt?
&hooks=`spam,email,math,formit2db,redirect`
&emailSubject=`Fast Question`
&preHooks=`db2formit`
&prefix=`cont_`
&packageName=`contact_fast`
&tablename=`fast_form`
&customValidators=`mathValidator`,
&emailTpl=`FastQuestionResult`
&emailTo=`[email protected]`
&emailCC=`[email protected]`
&redirectTo=`341`
&submitVar=`fastqsub`
&validate=`workemail:blank,math:required:mathValidator,fastq_name:required,fastq_surname:required,fastq_email:email:required,fastq_text:required`
]]
Mathvalidator Snippet
if (trim($value) == "") return true; // exit if blank text box
$value = $value; // the input value in the field math
$op1 = intval( $_POST['op1']) ; // intval() to be sure the value of op1 and op2 are treated as numbers
$op2 = intval($_POST['op2']) ;
$operator = $_POST['operator'] ; // value of field operator (should be + or - )
switch($operator){
case '+':
$goodresult = $op1 + $op2; // result if operator is 'plus' ...
if($value!=$goodresult){ // if answer not equal expected result
//$validator->addError('math', 'The answer is false.');
$validator->addError('math', 'the value should be '.$value);
return false;
}
break;
case '-':
$goodresult = $op1 - $op2;
if($value!=$goodresult){
$validator->addError('math', 'the value should be '.$value);
return false;
}
break;
}
return true;
Any help would be appreciated