Results 1 to 10 of 10

Thread: Integrating Securimage CAPTCHA?

  1. #1
    Join Date
    Feb 2008
    Posts
    1

    Default Integrating Securimage CAPTCHA?

    Hi,

    I've just started using FormMail and am looking to integrate a PHP CAPTCHA into my forms. I really like the look of Securimage (http://www.phpcaptcha.org/) but being new to PHP I'm unsure exactly how to complete the integration.

    The Quickstart guide on the Securimage sit contains the following instructions:
    1. Open the PHP file that processes the form data after submission. You can find this by looking at the action value inside your <form> tag.
      Note: In order to use Securimage, your form processor must be written in PHP.
    2. On line 1 of the file, add the following code:
      <?php session_start(); ?>
      It is important to put this at the top of the file before any HTML output.
    3. The next few steps will vary depending on how form validation is handled in your code.
    4. To check if the code is correct, we will make a call to the Securimage class. The following php code should be integrated into the script that processes your form near any error checking that takes place. It should be between <?php ?> tags.
      include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';

      $securimage = new Securimage();


      This includes the file that contains the Securimage code and creates a new Securimage object.
    5. Next we will actually check to see if the code was correct.
      if ($securimage->check($_POST['captcha_code']) == false) {
      // the code was incorrect
      // handle the error accordingly with your other error checking

      // or you can do something really basic like this
      die('The code you entered was incorrect. Go back and try again.');
      }

      The call to the check method checks the generated CAPTCHA code to the code entered by the user. If the code was incorrect, we use die to stop the script from executing and preventing the form from being submitted. The user must go back and try again.
    The question I now have is where abouts in the FormMail script do I insert the code from steps 4 and 5???

    Any help would be much appreciated.

    Cheers

    John

  2. #2
    Join Date
    Feb 2008
    Posts
    9

    Default Re: Integrating Securimage CAPTCHA?

    being new myself, id say you dont insert it in the file, you use the hook, and put it in there. lookup hook on this site

  3. #3
    Join Date
    May 2008
    Posts
    1

    Default Re: Integrating Securimage CAPTCHA?

    You should add it at the very top of the formmail.php file. also, you might want to use a header("Location: ") type redirect rather then die() on fail, it would look much better it would look like this:
    PHP Code:
    01: <?php
    02
    //start of captcha check
    03session_start();
    04: include_once $_SERVER['DOCUMENT_ROOT'].'/securimage/securimage.php';
    05
    06$securimage = new Securimage();
    07:
    08: if ($securimage->check($_POST['captcha_code']) == false)
    09: {
    10:        header("Location: /path/to/error_in_captcha.html");
    11:        die("sorry, captcha failed!!");
    12: }
    13:
    14// end of captcha check
    error_in_captcha.html can be any custom page with any name. The die() after the header call is just for good measures, theres no reason why the redirect shouldnt stop the rest of the script.

    Custom captchas don't require any logic from within the formmail, so theres no reason to try to embed it deep within it formmail. Just have it at the very top so that the script will fail immediately if the captcha is false, and then contenue as if it wasn't there on a good captcha.
    Last edited by closetgeek; 03-May-2008 at 05:09 PM.

  4. #4
    Join Date
    May 2008
    Posts
    1

    Default Re: Integrating Securimage CAPTCHA?

    Here's another guide about integrating it into FormMail for those who may need it in the future.

    http://www.phpcaptcha.org/documentat...tite-formmail/

  5. #5
    Join Date
    Apr 2008
    Posts
    30

    Default Re: Integrating Securimage CAPTCHA?

    Drew010, Great instructions, good detail and examples. Made it very easy to set up.

    Now just one problem after following your instructions, don't know if this is part of Securimage or another mistake I have, most likely could be something else I have incorrect.

    Everything works like it should except once the form is submitted it brings up a blank formmail.php page instead of a good_url success page.

    Can anyone shed some light on this?

    http://www.dinospizzausa.com/contact.htm

    Any help greatly appreciated.

  6. #6
    Join Date
    Feb 2011
    Posts
    4

    Default Re: Integrating Securimage CAPTCHA?

    @Rselby - Did you ever figure this out?

  7. #7
    Join Date
    Jun 2011
    Posts
    2

    Default Re: Integrating Securimage CAPTCHA?

    Quote Originally Posted by rselby View Post
    Drew010, Great instructions, good detail and examples. Made it very easy to set up.

    Now just one problem after following your instructions, don't know if this is part of Securimage or another mistake I have, most likely could be something else I have incorrect.

    Everything works like it should except once the form is submitted it brings up a blank formmail.php page instead of a good_url success page.

    Can anyone shed some light on this?

    http://www.dinospizzausa.com/contact.htm

    Any help greatly appreciated.
    I know this was posted some time ago, but for future users, a blank pages indicates a parsing error in formmail.php. Look for unclosed or extra braces or misspellings.
    I am having problems with autoresponding when using Securimage Captcha. Does anybody have a solution for that?
    Thanks.

  8. #8
    Join Date
    Jun 2011
    Posts
    2

    Red face Re: Integrating Securimage CAPTCHA?

    Quote Originally Posted by drew010 View Post
    Here's another guide about integrating it into FormMail for those who may need it in the future.

    http://www.phpcaptcha.org/documentat...tite-formmail/
    I found this link to be 404.

    I have been attempting to use SecurImage along with Formmail while using the AutoRespond feature. This was quite troublesome to me because the session variables in verifyimg.php are obviously not the same as the ones in securimage.php. To solve this problem I made these changes:
    I set this string, as in the Formmail instructions:
    Code:
                /* Help: http://www.tectite.com/fmdoc/require_captcha.php */
    $REQUIRE_CAPTCHA = "Please enter the Security Code";          // set to a message string if your forms
                                    // must provide a CAPTCHA string
    I inserted this code into the REQUIRE_CAPTCHA condition:
    Code:
     if ($REQUIRE_CAPTCHA !== "")
        { 
    // replacing imgverify with securimage
      session_start();
    
    // including securimage captcha code
      include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';
      $securimage = new Securimage();
    
    // setting verifyimg session variable (otherwise it doesn't get set and auto respond won't work)
      $_SESSION['VerifyImgString'] = $_POST['arverify'];
    
      if ($securimage->check($_POST['arverify']) == false) {
        // the code was incorrect
        // you should handle the error so that the form processor doesn't continue
       // using the error handler from formmail
       $b_bad = true;
    
        // or you can use the following code if there is no validation or you do not know how
        /*echo "The security code entered was incorrect.<br /><br />";
        echo "Please go <a href='javascript:history.go(-1)'>back</a> and try again.";
        exit;*/
      } 
    // commenting out imgverify comparsion
           /* if ($SPECIAL_VALUES["imgverify"] === "")
            {
                $s_missing .= "$REQUIRE_CAPTCHA\n";
                $a_missing_list[] = "$REQUIRE_CAPTCHA";
                $b_bad = true;
            }*/
        }
        return (!$b_bad);
    }
    I hope this helps someone...

  9. #9
    Join Date
    Jul 2011
    Posts
    1

    Default Re: Integrating Securimage CAPTCHA?

    Hi all, I know this post has been a while - but I wonder if it has been solved? The link above does not work anymore and I have the similiar problem'ish.

  10. #10
    Join Date
    Mar 2012
    Posts
    1

    Default Re: Integrating Securimage CAPTCHA?

    I can't get Secureimage to redirect on success. I can get it to generate an echo okay, it's just that when I change it to a header(), it fails. Any help would be greatly appreciaed! (and yes, I'm a php noob)

    Here's my form processor:

    <?php session_start(); ?>


    <?PHP
    // Form Variables
    $to = "my@mywebsite.com";
    $subject = "Form Response";
    $headers = "Form Response";
    $forward = 1; // redirect? 1=yes 0=no
    $location = "/thank-you.php"; // redirect target (if redirect is set to 1)
    $date = date ("l, F jS, Y");
    $time = date ("h:i A");
    $msg = "Form Response, submitted on $date at $time.\n\n";


    include_once $_SERVER['DOCUMENT_ROOT'] . '/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
    echo "The security code entered was incorrect.<br /><br />";
    echo "Please go <a href='javascript:history.go(-1)'>back</a> and try again.";
    exit;
    }
    if ($_SERVER['REQUEST_METHOD'] == "POST") {
    foreach ($_POST as $key => $value) {
    $msg .= ucfirst ($key) ." : ". $value . "\n";
    }
    }
    else {
    foreach ($_GET as $key => $value) {
    $msg .= ucfirst ($key) ." : ". $value . "\n";
    }
    }
    mail($to, $subject, $msg, $headers);
    if ($forward == 1) {
    header ("Location: /thank-you.php");
    }
    else {
    echo "Thank you.";
    }
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Adding Securimage Captcha to Formail?
    By CybaGirl in forum HOWTO Guides and Tips
    Replies: 10
    Last Post: 25-Apr-2011, 07:36 PM
  2. verifyimg CAPTCHA works, CAPTCHA Creator doesn't
    By phper in forum Community Support
    Replies: 15
    Last Post: 22-Apr-2009, 08:43 PM
  3. Trouble integrating image verification into existing form
    By chrismr2 in forum Community Support
    Replies: 4
    Last Post: 22-Jul-2008, 06:44 PM
  4. Negative Captcha or Reverse Captcha
    By russellr in forum HOWTO Guides and Tips
    Replies: 0
    Last Post: 19-Jun-2008, 09:49 PM
  5. Re: Integrating Securimage CAPTCHA?
    By rselby in forum Features Questions
    Replies: 3
    Last Post: 23-May-2008, 02:55 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •