Menu

getting "invalid captcha string" with correct

Help
W4Designs
2009-02-13
2013-06-03
  • W4Designs

    W4Designs - 2009-02-13

    When submitting my new form, I'm getting "invalid captcha string" with correct captcha entry.

    Any ideas?

    I'm using the online form generator.

    Thanks!

     
    • TNTEverett

      TNTEverett - 2009-02-13

      I have never actually experienced this problem but here is what is supposed to happen. 
      The form file calls a program "CaptchaSecurityImages.php" that generates an image with a security code. 
      The security code is stored as a session variable for later compare. 
      You type in the code displaayed in teh image that should match the code staored in the session variable. 
      When you submit your form the program "processor.php" takes the form field and compares it to the stored session variable. 
      If they don't match you get the error message. 
      This is a very simple sequence and can only be broken if session variables are not turned on or the sessions are somehow being destroyed between form.html and processor.php. 
      My opinion, it is probably that your host does not turn on session variables by default. 
      Check with them and then get back to this forum for more help. 

      You can also run this on your site to see if session variables are enabled. 
      filename: phpenv.php

      <html><body><center>
      <a href="/a/">Back</a><br><br>

      <?php
      function ss_timing_start ($name = 'default') {
          global $ss_timing_start_times;
          $ss_timing_start_times[$name] = explode(' ', microtime());
      }

      function ss_timing_stop ($name = 'default') {
          global $ss_timing_stop_times;
          $ss_timing_stop_times[$name] = explode(' ', microtime());
      }

      function ss_timing_current ($name = 'default') {
          global $ss_timing_start_times, $ss_timing_stop_times;
          if (!isset($ss_timing_start_times[$name])) {
              return 0;
          }
          if (!isset($ss_timing_stop_times[$name])) {
              $stop_time = explode(' ', microtime());
          }
          else {
              $stop_time = $ss_timing_stop_times[$name];
          }
          // do the big numbers first so the small ones aren't lost
          $current = $stop_time[1] - $ss_timing_start_times[$name][1];
          $current += $stop_time[0] - $ss_timing_start_times[$name][0];
          return $current;
      }

      ss_timing_start();
      phpinfo();
      ss_timing_stop();
      ?>

      <hr><br><font color="red" size=4> The page was executed in: <?php echo ss_timing_current();?>  seconds. </font><br><br>
      <a href="/a/">Back</a>
      </center></body></html>

      You would be looking for:
      Session Support  enabled 

       
    • W4Designs

      W4Designs - 2009-02-13

      OK, I ran the file you suggested and sessions are enabled. I'm puzzled.

       
      • TNTEverett

        TNTEverett - 2009-02-14

        Find this section of code in your processor.php file:

        else {
          echo "Invalid Captcha String.";
        }

        Change it to this:

        else {
          echo "<li>Session Code: ".$_SESSION['security_code']."<br />";
          echo "<li>Typed Code: ".$_POST['security_code']."<br />";
          echo "Invalid Captcha String.";
        }

        This will print the two variables being tested.  If they don't match you get the invalid message.  Let me know what you get. 

         

Log in to post a comment.