Help please with captcha html code

4 replies
I am trying to add a captcha to my website to stop spam it , I have added a captcha code to my current mail form, and it appears to show correctly but on close look you can still send a email without using the captcha, have I put the captcha in the wrong place? any help would be very grateful.
this is the mail form:
<form action="http://cgi.uk2.net/cgi-bin/uk2-formmail.pl" method="POST">
<input type="hidden" name="recipient" value="cp124@cometoportugal.com">
<!--- do not change this line --->
<input type="hidden" name="print_config" value="email,subject">
<!--- input all your own fields in sort the order your want them --->
<input type="hidden" name="sort" value="order:message">
<input type="hidden" name="required" value="email,Your Name:,message">
<input type="hidden" name="print_blank_fields" value="1">
E-mail address?<br>
<input type="text" size="35" name="email" value=" "><br>
<input type="hidden" name="realname" value="COMETOPORTUGAL">
<input type="hidden" name="subject" value="Property Enquiry for CP141">
<br>Your Name:<br>
<input type="text" size="35" maxlength="30" name="Your Name:" value=" "><br>
Message<br>
<textarea name="message" rows="2" cols="40"> </textarea><br>
<input type="submit" value="Send message"><input type="reset" value="Clear Form">
</form>
and this is the captcha:
html>
<head>
<title>Captcha</title>

<script type="text/javascript">

//Created / Generates the captcha function
function DrawCaptcha()
{
var a = Math.ceil(Math.random() * 10)+ '';
var b = Math.ceil(Math.random() * 10)+ '';
var c = Math.ceil(Math.random() * 10)+ '';
var d = Math.ceil(Math.random() * 10)+ '';
var e = Math.ceil(Math.random() * 10)+ '';
var f = Math.ceil(Math.random() * 10)+ '';
var g = Math.ceil(Math.random() * 10)+ '';
var code = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' '+ f + ' ' + g;
document.getElementById("txtCaptcha").value = code
}

// Validate the Entered input aganist the generated security code function
function ValidCaptcha(){
var str1 = removeSpaces(document.getElementById('txtCaptcha') .value);
var str2 = removeSpaces(document.getElementById('txtInput').v alue);
if (str1 == str2) return true;
return false;

}

// Remove the spaces from the entered and generated code
function removeSpaces(string)
{
return string.split(' ').join('');
}


</script>
the webpage that has the complete for on is:
http://www.cometoportugal.com/properties/page122.html
#captcha #code #html
  • Profile picture of the author KirkMcD
    What forces people to press the "check" button?
    On Submit, you need to check the captcha. It should be stored and validated on the server, not the browser page.
    {{ DiscussionBoard.errors[7203153].message }}
    • Profile picture of the author algarve
      Originally Posted by KirkMcD View Post

      What forces people to press the "check" button?
      On Submit, you need to check the captcha. It should be stored and validated on the server, not the browser page.
      do I upload the captcha to my server or the mail form complete with captcha? I do not think anything forces the check button this is why I am asking if the captcha HTML code it in the right place
      {{ DiscussionBoard.errors[7203358].message }}
  • Profile picture of the author Dong Lee
    you need to bind call to captcha on your send button.. Use onclick method and call your javascript method
    {{ DiscussionBoard.errors[7257621].message }}
  • Profile picture of the author ashok999333
    Why you are writing your own captcha? You can easily implement it using the codes from the providers. Go to captcha(dot)net and register your site get your free captcha code.

    Captcha(dot)net provides services to lot of leading sites and it is very tough to crack too.
    {{ DiscussionBoard.errors[7259259].message }}

Trending Topics