Witajcie mam formularz z kilkoma polami z funkcją sparwdzania czy pole zostało wypełnione, niestety od pewnego czasu atakuje mnie spam

i postanowiłem dodać captcha do formularza. Dodałem skrypt pokazuje się obrazek a w nim tekst można nawet go odwsieżyć

, ale coś nie działa bo moge nadal wysyłać wiadomość bez podania kodu . problem napewno leży w dodaniu tego fragmentu kodu
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . 'http://xxxxxxxxxxxxxxx/securimage/securimage.php';
$securimage = new Securimage();
if ($securimage->check($_POST['captcha_code']) == false) {
// the code was incorrect
// you should handle the error so that the form processor doesn't continue
// or you can use the following code if there is no validation or you do not know how
echo "The security code entered was incorrect.<br /><br />"; echo "Please go <a href='java script:history.go(-1)'>back</a> and try again."; }
?>
Bo niezabardzo wiem gdzie go dać i czy nie potrzebuje on modyfikacji
Oto mój kod wraz ze wstawionym fragment :
<?php if(isset($page['sended']) && $page['sended'] == 1):?> <p class="tcent">
<?php if($page['status'] == 1):?>
<span class="biggerb">Thank You for filling the form.</span><br />
<?php else: ?>
<?php if($page['status'] == 2):?>
<span class="bigger redb">Wrong email.</span><br />
<?php else: ?>
<span class="bigger redb">Error. Please correct data in form.</span><br />
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . 'http://xxxxxxxxxxxxx/securimage/securimage.php';
$securimage = new Securimage();
if ($securimage->check($_POST['captcha_code']) == false) {
// the code was incorrect
// you should handle the error so that the form processor doesn't continue
// or you can use the following code if there is no validation or you do not know how
echo "The security code entered was incorrect.<br /><br />"; echo "Please go <a href='java script:history.go(-1)'>back</a> and try again."; }
?>
<?php endif; ?>
<?php endif; ?>
<a href="eng/contact_us">back</a>
</p>
<?php else: ?>
<noscript><noscript>Correctly working form needs javascript enabled</noscript></noscript>
<form action="" method="post" class="u_form" id="contact_form">
<fieldset>
<table cellpadding="1" cellspacing="1" class="tleft mleft10" width="565">
<tbody>
<tr>
<td width="180"><label for="first_name" class="bld">First name:</label></td>
<td><span class="red bigger">*</span> <input type="text" id="first_name" name="first_name" class="txt longer" /></td>
</tr>
<tr>
<td width="180"><label for="last_name" class="bld">Last name:</label></td>
<td><span class="red bigger">*</span> <input type="text" id="last_name" name="last_name" class="txt longer" /></td>
</tr>
<tr>
<td><label for="email" class="bld">Email:</label></td>
<td><span class="red bgger">*</span> <input type="text" id="email" name="email" class="txt longer" /></td>
</tr>
<tr>
<td><label for="tel" class="bld">Telephone:</label></td>
<td><span class="white bigger">*</span> <input type="text" id="tel" name="tel" class="txt longer" /></td>
</tr>
<tr>
<td><label for="enquiry" class="bld">Your enquiry :</label></td>
<td><span class="red bigger">*</span> <textarea id="enquiry" name="enquiry" class="longer"></textarea></td>
<tr>
<tr>
<td ><label for="enquiry" class="bld">Write code below: <p>
<img id="captcha" src="xxxxxxxxxxxxx/securimage/securimage_show.php" alt="CAPTCHA Image" /><p><a href="#" onclick="document.getElementById('captcha').src = 'xxxxxxxxxxxxxxxx/securimage/securimage_show.php?' + Math.random(); return false">[ Different Image ]</a></td>
<td><span class="red bigger"></span><input type="text" name="captcha_code" size="10" maxlength="6" /><br>
</td>
<tr>
<td colspan="2" class="tright"><input type="submit" name="send" id="send" class="subm subm_bigger" value="Send" />
</tr>
</tbody>
</table>
</fieldset>
</form><br />
<div class="hr"></div><br />
<script type="text/javascript">
$(document).ready(function() {
$('#contact_form').validate({
rules: {
first_name: { required: true, minlength: 3},
last_name: { required: true, minlength: 3},
email: {required:true,email: true},
enquiry: {required:true, minlength:5}
},
messages: {
first_name: "Field First name is required",
last_name: "Field Last name is required",
email: "Field Email is required",
enquiry: "Field enquiry is required"
}
});
});
</script>
<?php endif; ?>
Proszę o pomoc albo naprowadzenie mnie na dobrą scieżkę, bo siedze już nad tym trochę i nie wiem co zrobić