FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
easy solution for Captcha without the API - Formtools v2.X
#1
I have been using formtools for a few years now.
Since I saw lots of requests for using a Captcha without the API ( tested under Formtools version v2.0.2 , should fit the whole 2.x branch)
I decided to contribute this easy solution to this nice community.


So I dedicated a few minutes to clean the Hebrew from it and turn it into English for you to use ..... with my peace blessings from Israel :-)

First of all go to http://www.phpcaptcha.org/ and download the "Securimage" files.
put the files under the main formtools directory (formtools/securimage/)

open your formtools/process.php , save it under a new name - lets say "processC.php" - it will be used for all your captcha-enabled forms.

NOW edit the file ("processC.php"):

the first line:
Code:
<?php

should turn into:

Code:
<?php
session_start();

around line 100 - AFTER these lines

Code:
// do we have a form for this id?
  if (!ft_check_form_exists($form_id))
  {
    $page_vars = array("message_type" => "error", "message" => $LANG["processing_invalid_form_id"]);
    ft_display_page("../../global/smarty/messages.tpl", $page_vars);
    exit;
  }

ADD THE CODE:

Code:
// Tzvook captcha
$folder = dirname(__FILE__);
@include_once("$folder/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
$page_vars = array("message_type" => "error", "message" => "<center><div style=\"width: 500px; border: 1px solid #FF0000; background-color: #FFFFFF; padding: 30px; font-family: Tahoma, Arial; font-size: 16px; color: #000000; margin: 0 auto;\">You did not typed the right verification code<br /><br />The verification code is checking to see if you are really humans<br />and not a SPAM automatic robots</strong><br /><br />Please go back and try again<br /><br /><A href=\"javascript:history.back(-1)\" onmouseover='window.status = \"\" ;return true'>Back to the form</a></div></center>");
        ft_display_page("../../global/smarty/messages.tpl", $page_vars);
        exit;
}
//  End Tzvook captcha
==============================================

Your forms need to go to the new file:
something like - <form action="http://www.your-domain.com/formtools/processC.php" method="post">

and the captcha itself, wherever you need it in your form:

Code:
<img id="captcha" src="http://www.your-domain.com/formtools/securimage/securimage_show.php" alt="CAPTCHA Image" alt="Security Image" style="padding-left: 4px;" align="right" />
<font size="1">copy the code to the field:</font><br />
<input type="text" name="captcha_code" size="10" maxlength="6" />
<a href="#" onclick="document.getElementById('captcha').src = 'http://www.your-domain.com/formtools/securimage/securimage_show.php?' + Math.random(); return false">[ Different Image ]</a>

There are a lot of nice features @ http://www.phpcaptcha.org/ ... all those can be inserted in your forms ... I simply gave the easiest implementation ...

It's a quick solution - I just made it and didn't had too many tests - but it seems to work perfectly, I'll be glad to hear if you had issues with it ..

..
Reply
#2
Thanks! I struggled with the API and was unsuccessful. This works great.
Reply
#3
:-)
glad to hear ....
If there were no comment, it probably works as expected for all ...
Reply
#4
Awesome! Thanks for sharing with our community!
Reply
#5
Thanks for adding this!

Just a note, but I think that this:

ft_display_page("../../global/smarty/messages.tpl", $page_vars);

should be changed to something like

ft_display_page("error.tpl", $page_vars);

I don't think ../../global/smarty/messages.tpl exists... at least I didn't see it on my install.
Reply
#6
I'm having trouble making it work. For some reason I was able to get through the form setup process fine but now the captcha won't verify the image. Here is my form: http://www.imnotaclown.com/library/

I tried making the changes as moorezilla suggested but that didn't seem to work either.

Suggestions? Thank you.

(Jan 30th, 2013, 10:49 AM)moorezilla Wrote: Thanks for adding this!

Just a note, but I think that this:

ft_display_page("../../global/smarty/messages.tpl", $page_vars);

should be changed to something like

ft_display_page("error.tpl", $page_vars);

I don't think ../../global/smarty/messages.tpl exists... at least I didn't see it on my install.

Reply
#7
Is there any way to have the error page a custom one of your own?
Reply
#8
yes, still pretty much correct as of today, BEST solution yet!
Reply
#9
Hi,

can someone help me, and explain me where I can set the action on the form?
When I look in the formbuilder/published directory and have a look in the code of my form there is no <form action...>


Your forms need to go to the new file:
something like - <form action="http://www.your-domain.com/formtools/processC.php" method="post">


and also, how can I add the below catcha code to forms built with formbuilder?

and the captcha itself, wherever you need it in your form:

Code:
<img id="captcha" src="http://www.your-domain.com/formtools/securimage/securimage_show.php" alt="CAPTCHA Image" alt="Security Image" style="padding-left: 4px;" align="right" />
<font size="1">copy the code to the field:</font><br />
<input type="text" name="captcha_code" size="10" maxlength="6" />
<a href="#" onclick="document.getElementById('captcha').src = 'http://www.your-domain.com/formtools/securimage/securimage_show.php?' + Math.random(); return false">[ Different Image ]</a>


thanks in advance,

Kan
Reply
#10
Hi Kan, did you or anyone else figure out how to get the captcha to work on the form? I try pasting the code but it never works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)