Results 1 to 3 of 3

Thread: [RESOLVED] Captcha ?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Wisconsin
    Posts
    788

    Resolved [RESOLVED] Captcha ?

    I am looking at reCAPTCHA. When I try to view the sample code the page is not rendered correctly.
    PHP Code:
    <html>
      <body>
        <form action="" method="post">
    <?php

    require_once('recaptchalib.php');

    // Get a key from http://recaptcha.net/api/getkey
    $publickey "";
    $privatekey "";

    # the response from reCAPTCHA
    $resp null;
    # the error code from reCAPTCHA, if any
    $error null;

    # was there a reCAPTCHA response?
    if ($_POST["recaptcha_response_field"]) {
            
    $resp recaptcha_check_answer ($privatekey,
                                            
    $_SERVER["REMOTE_ADDR"],
                                            
    $_POST["recaptcha_challenge_field"],
                                            
    $_POST["recaptcha_response_field"]);

            if (
    $resp->is_valid) {
                    echo 
    "You got it!";
            } else {
                    
    # set the error code so that we can display it
                    
    $error $resp->error;
            }
    }
    echo 
    recaptcha_get_html($publickey$error);
    ?>
        <br/>
        <input type="submit" value="submit" />
        </form>
      </body>
    </html>

    everything in the code after the > in $resp-> is_valid shows on the page.

    Any hints as to what I am doing wrong....

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Captcha ?

    What do you mean exactly? It prints the php code in the webbrowser?

    One mistake I see is that you haven't put the $publickey and $privatekey values (unless you removed them to post here).


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Wisconsin
    Posts
    788

    Re: Captcha ?

    I figured that one out. I did not have the javascript on the page to enable the captcha.
    <script type="text/javascript"
    src="http://api.recaptcha.net/challenge?k=<>">
    </script>



    I have another problem with the page though.

    The submit button does not appear on the page??

    Code:
                                        <tr>
                                            <td>
                                                <script type="text/javascript"
                                                   src="http://api.recaptcha.net/challenge?k=<>">
                                                </script>    
                                                <?php
    
                                                require_once('recaptchalib.php');
    
                                                // Get a key from http://recaptcha.net/api/getkey
                                                $publickey = "";
                                                $privatekey = "";
    
                                                # the response from reCAPTCHA
                                                $resp = null;
                                                # the error code from reCAPTCHA, if any
                                                $error = null;
    
                                                # was there a reCAPTCHA response?
                                                if ($_POST["recaptcha_response_field"]) {
                                                        $resp = recaptcha_check_answer ($privatekey,
                                                                                        $_SERVER["REMOTE_ADDR"],
                                                                                        $_POST["recaptcha_challenge_field"],
                                                                                        $_POST["recaptcha_response_field"]);
    
                                                        if ($resp->is_valid) {
                                                                echo "You got it!";
                                                        } else {
                                                                # set the error code so that we can display it
                                                                $error = $resp->error;
                                                        }
                                                }
                                                echo recaptcha_get_html($publickey, $error);
                                                ?>
                                                
                                            </td>
                                            <td><input type="submit" value="Submit Request" /></td>
    <!--                                        <td width=500><input type="submit" value="Submit Request" /></td>-->
                                        </tr>
    Last edited by mojo69; Dec 29th, 2008 at 12:09 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width