• I have followed the instructions for adding captcha to a custom form.
    The captcha field displays fine.
    When I validate it, the captcha response is always success, even if it is wrong or blank.
    I am fairly good with PHP/HTML, so I am confident I have done it correctly.
    The wordpress site is running in a subdomain – could this be a problem?

    Otherwise, my form starts:
    <form name="myform" action="../process2.php" method="POST">

    The validation performed in process2.php is:

    session_start();
    
    //Check whether the form has been submitted
    if (array_key_exists('check_submit_signupnow2', $_POST)) {
    
      unset($_SESSION['source']);
    
      // validation
    
      // first name is mandatory
      if ((!isset($_POST['process_fname'])) || ($_POST['process_fname'] == '')){
        $_SESSION['error'] = 'Please enter your first name';
        $_SESSION['source'] = 'ERROR';
      }
      // check CAPTCHA code
      if( function_exists( 'cptch_check_custom_form' ) && cptch_check_custom_form() !== true ) {
        $_SESSION['error'] = 'Please enter the correct Captcha code';
        $_SESSION['source'] = 'ERROR';
      }

    etc etc

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    I know it all fits together well, as if I leave the firstname blank, my form redisplays correctly with the error message.
    However, the captcha never fails, even if its wrong or empty..

    You can try it yourself here: http://sentinel.vanstonetrading.com/ and just press either of the buttons on the home page

    Can you help me?

    Cheers,
    Bruce

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The use of !== may be inappropriate? If cptch_check_custom_form() returns an actual boolean true or false, all you need to do is if( function_exists( 'cptch_check_custom_form' ) && !cptch_check_custom_form() )

    If that’s not it, the fault may lie in the cptch_check_custom_form() function itself.

Viewing 1 replies (of 1 total)
  • The topic ‘custom form, captcha always succeeds’ is closed to new replies.