The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
MathCAPTCHA - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1)
+--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5)
+--- Thread: MathCAPTCHA (/showthread.php?tid=881)



MathCAPTCHA - Mike - Oct 7th, 2010

reCAPTCHA is good if your users speak English - they can guess the word, because they know it. Those who do not speak English, forced to guess each letter that is not always possible. There is a universal language that everyone knows: the mathematics. So I wrote a CAPTCHA script prompts the user to solve a simple equation:[attachment=76]

N.B. I assume that you are using Form Tools API method to submit your form.

To use it in your form, unzip and upload folder "captcha" to your webserver.

1) If you not using server-side validation.
  1. In you form, after:
    PHP Code:
    $fields ft_api_init_form_page(YOUR_FORM_ID); 
    add:
    PHP Code:
    $errors = array();
    if (isset(
    $_POST["NAME_OF_SUBMIT_BUTTON"]))
    {
        if (
    $_POST["math_c_val"] != $_SESSION["math_c_sum"])
            {
                
    $errors["math_captcha"] = "Sorry, you entered an incorrect CAPTCHA number.";
            }
        if (empty(
    $errors))
        { 
    next, after:
    PHP Code:
    ft_api_process_form($params); 
    add:
    PHP Code:
        }
        else 
        {
            
    $fields array_merge($_SESSION["form_tools_form"], $_POST);
        }


  2. To display error message on page, add somewhere after <body>:
    PHP Code:
    <?php
    if (!empty($errors))
    {
      echo 
    "<div class='error'>Please fix the following errors:\n<ul>";
      foreach (
    $errors as $error)
      echo 
    "<li>$error</li>\n";
      echo 
    "</ul></div>"
    }
    ?>

  3. Use this tutorial to re-fill fields if CAPTCHA entered improperly: Re-filling form fields using the API.

1) If you using server-side validation
  1. In you form, after:
    PHP Code:
    $errors validate_fields($_POST$rules); 

    add:
    PHP Code:
        if ($_POST["math_c_val"] != $_SESSION["math_c_sum"])
            {
                
    $errors["math_captcha"] = "Sorry, you entered an incorrect CAPTCHA number.";
            } 
2) Add in your form:
Code:
Solve this simple equation: <img src="/captcha/math_captcha.php"> = <input type="text" name="math_c_val" maxlength="5" size="5">


Now, if everything works right, you will see something like this:[attachment=75]

You can tune CAPTCHA image by changing parameters in section "Config" in file "math_captcha.php"


RE: MathCAPTCHA - Ben - Oct 8th, 2010

Very cool! Thanks for posting your code!

- Ben