Results 1 to 7 of 7

implement captcha

This is a discussion on implement captcha within the Programming forums, part of the Web Designing & Development category; For users who have a solid grounding in PHP and how HTML forms work, this example will show how to ...

  1. #1
    Senior Member Array akash's Avatar
    Join Date
    Oct 2008
    Location
    Heaven (Earth)
    Posts
    500

    Default implement captcha

    For users who have a solid grounding in PHP and how HTML forms work, this example will show how to implement a captcha test:

    1. Enable the GD extention in your site's PHP settings by logging into OnSite. Once you are logged in go to the PHP Configurator which is under the Other Tools heading. Within the PHP Configurator click on the Extensions link on the left hand side of the page. You will now see a heading for Graphics, make sure the checkbox for the GD extention is checked. Now click on the Save Changes button near the top of the page.


    2. Download (in Firefox, right-click and choose "Save link as..." or in Internet Explorer, right-click and choose "Save target as...") this captcha-gen.php PHP script and place it in the same directory as your form.


    3. Add the following image and text input to your form:
    Code:
          <img src="captcha-gen.php" width="200" height="80"> <br />
          Captcha Text: <input type="text" name="phrase">
    4. Inside the action script of your form, make sure to call session_start(); and add the following check before you process the form information.
    Code:
          <?php
    
          if( isset($_REQUEST['phrase']) &&
              isset($_SESSION['phrase']) &&
              strlen($_REQUEST['phrase']) > 0 &&
              strlen($_SESSION['phrase']) > 0 )
          {
    
            if( $_REQUEST['phrase'] == $_SESSION['phrase'] )
            {
    
             //This is where you will process the form input.
    
             //This will prevent the form from being
             //resubmitted multiple times.
             unset($_SESSION['phrase']);
            }
            else
            {
    
               //This is where you want to process
               // a bad guess at the Captcha phrase.
    
               print( "I'm sorry the Captcha phrase was incorrect!" );
            }
    
          }
          else
          {
    
            //This is where you want to process
            // a direct request or a re-submision
            // after the phrase was removed from
            // the session.
    
            print( "You must pass the Captcha test to use this form!" );
    
          }
    
          ?>

    Make sure that all three of the above files are in the same directory and it should work.

    The above method uses a PEAR module to create the captcha image. You can either look at the source code of captcha-gen.php or look at the Test_CAPTCHA site http://pear.php.net/package/Text_CAPTCHA/docs to learn more. The site also has another example of how to implement a captcha test.

    You can read more about the CAPTCHA project here: Captcha.net

  2. #2
    Junior Member Array
    Join Date
    Feb 2009
    Posts
    15

    Default Re: implement captcha

    That's cool, I already have a captcha script that I created myself. But another neat thing to do is to create one that uses a math equation instead of an image.

  3. #3
    Senior Member Array akash's Avatar
    Join Date
    Oct 2008
    Location
    Heaven (Earth)
    Posts
    500

    Default Re: implement captcha

    That is good plz share it with us.
    post you script here.

  4. #4
    Member Array
    Join Date
    May 2009
    Posts
    60

    Default Re: implement captcha

    nice share

  5. #5
    Senior Member Array
    Join Date
    Mar 2011
    Posts
    110

    Default Re: implement captcha

    It is a very useful tool,thanks a lot for sharing this.

  6. #6
    Member Array
    Join Date
    Nov 2011
    Posts
    33

    Default Re: implement captcha

    Captcha code used in the most of in register page.Now a days Captcha code implement by the PHP.By Using PHP securtiy makes the high.

  7. #7
    Member Array
    Join Date
    Jan 2012
    Posts
    84

    Default Re: implement captcha

    Thanks for sharing this post.I really appreciate your work.



Similar Threads

  1. Tutorial to Create Captcha in Vb .Net
    By sagar4evr in forum Programming
    Replies: 5
    Last Post: 08-20-2010, 09:47 AM
  2. Captcha
    By akash in forum Programming
    Replies: 0
    Last Post: 02-04-2009, 06:44 AM
  3. Stumbleupon adds the captcha code
    By SticKer in forum Member Discussion
    Replies: 8
    Last Post: 03-20-2008, 05:04 PM

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
  •  
SEO Forum | Web Hosting Forum | Websites For Sale |