Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    TrainReq
    Guest

    Putting in captcha

    I would like to know how to put a catpcha in my existing form... right now i have the form as well as the form output on the index page.... how would i go about making it have a capcha code to where inorder for the form to go through... they would need to enter a captcha code.

  • #2
    New Coder
    Join Date
    Dec 2006
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi, check out hotscripts.com. They have many Captcha scripts with instructions.

  • #3
    TrainReq
    Guest
    yes... but those are if your form and your form handler are seperate.. they are on the same php page.

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,044
    Thanks
    2
    Thanked 316 Times in 308 Posts
    Your code in a single file has conditional logic to separate the generation and output of the form from the processing of the submitted data, yes.

    The code that generates the catpcha must be placed within the conditional code that generates and outputs the form and the code that tests the value from the catpcha needs to be placed within the conditional code with the current form processing logic.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #5
    TrainReq
    Guest
    My site is http://urbanfriend.net .... http://nightstarproductions.com/index.phps is the URL to the source ... and http://nightstarproductions.com/captcha.phps is the source for the captcha image... what would i have to put in index.php to verify the captcha... and if someone enters the wrong captcha it wont let them join the train... but instead say: Invalid Verification code, please try again ... instead.
    Last edited by TrainReq; 12-21-2006 at 01:46 AM.

  • #6
    TrainReq
    Guest
    bump



    ---

  • #7
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,044
    Thanks
    2
    Thanked 316 Times in 308 Posts
    The first two links in your post don't work...
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #8
    TrainReq
    Guest
    Fixed the second link.. and the new site down... now have it up on http://urbanfriend.net .. that is the site .. the index.phps is the source.

  • #9
    TrainReq
    Guest
    bump



    -

  • #10
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,044
    Thanks
    2
    Thanked 316 Times in 308 Posts
    Your code has several forms. For any one of them, do something like the following -
    PHP Code:
    <?php
    session_start
    (); // form processing code uses a session, start session at top of page
    if(isset($_POST['subbutton'])){
    // the form processing code
    // check if the entered value matches the captcha code
        
    if($_POST['capcars'] != $_SESSION['vercode'])
        {
          die(
    "Error: The code entered did not match the image.");
        }else{
          
    // the normal processing code goes here
          
    echo 'You entered the code correctly';
        }
    } else {
    // the form code
    ?>
    <form method="post">
    Enter the characters you see in the image:&nbsp;&nbsp;<input type="text" name="capcars" size="5"> <img src="captcha.php" alt=""><br />
    <input type=submit name="subbutton" value="submit">
    </form>
    <?php
    }
    ?>
    This code works (tested) with your captcha.php file and the $_SESSION['vercode'] variable that it sets.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Posting Permissions

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