www.webdeveloper.com
Results 1 to 2 of 2

Thread: Problem using reCAPTCHA + AJAX

  1. #1
    Join Date
    Mar 2006
    Posts
    2

    Problem using reCAPTCHA + AJAX

    I'm using a script I found from dhtml goodies to make a simple html window appear over my site. All I want is a simple form, and I want to add spam protection for obvious reasons. Basically when you click on the link it creates a pop-up window and pulls the file infoform2.php. I've used reCAPTCHA with no problem before, but for some reason it won't display in the window. just to make sure it wasn't a file location problem, I copied/pasted the includes file for reCAPTCHA into infoform2.php.

    index.php (the main page where the link is)

    HTML Code:
    <div id="moreinfo"><a href="#" onclick="displayMessage('<?=$siteroot?>moreinfo/infoform2.php');return false">MORE<br />INFO &rsaquo;&rsaquo;</a></div>
    infoform2.php (this displays just fine when you view the page by itself, but within the AJAX window it doesn't work

    PHP Code:
    <?
    ##################
    #### TEMPLATE ####
    ##################

    function makeheader() {  //will house the header etc
        //echo "template template template template template template <br><br>";
        
    $pagetitle="Your Opinions";
        
    //$pageident="opinions";
        
    include('../header2.php');
    }

    function 
    makefooter() {
        include(
    '../footer.php');
    }

    function 
    submitinfo() {  //processes the form submission
    $name $_POST['name'];
    $email $_POST['email'];
    $phone $_POST['phone'];

    $to "cnurotaract@gmail.com";
    $subject "Someone is interested in CNU Rotaract!";
    $message "Make sure you contact them ASAP!  Here's their info:\n\n<b>Name:</b>  $name\n<b>Email:</b>  $email\nPhone:  $phone\n\nGenerated from www.cnurotaract.com";
    $from "membership@cnurotaract.com";
    $headers "From: $from";
    mail($to,$subject,$message,$headers);


    require_once(
    'recaptchalib.php');
    $privatekey "6Ld9cwIAAAAAAH8PI1-EnE2w3k3wZsOdmA1KbOKx";
    $resp recaptcha_check_answer ($privatekey,
                                    
    $_SERVER["REMOTE_ADDR"],
                                    
    $_POST["recaptcha_challenge_field"],
                                    
    $_POST["recaptcha_response_field"]);

    #comment out the if statement for testing purposes
    /*if (!$resp->is_valid) {
      die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
           "(reCAPTCHA said: " . $resp->error . ")");
    }*/

    ?>

    <h3>Thanks, <?=$name?>!  Your address "<?=$email?>" has been submitted.  We'll be in touch shortly!</h3>
    <?
    }


    ###################################################################################################
    ###################################### HOME #######################################################
    ###################################################################################################

    function home() {
        
    //include('opinions/config.php');?>
    <html><head><title></title></head>

    <form method="post" action="moreinfo/infoform2.php?submitinfo" onsubmit="return submitinfo()" name="moreinfo" class="moreinfo" id="moreinfo">
    <!--<form class="moreinfo" id="moreinfo" method="post" action="process.php">-->
    <table cols="2">
    <tr><td width="30%"><b>Name:</b></td><td width="70%"><input type="text" name="name" id="name" /></td></tr>
    <tr><td width="30%"><b>E-Mail:</b></td><td width="70%"><input type="text" name="email" id="email" /></td></tr>
    <tr><td width="30%"><b>Phone:</b></td><td width="70%"><input type="text" name="phone" id="phone" /></td></tr>
    <tr><td width="30%"><b>Spam Protection:</b></td><td width="70%">
    <?
    //require_once('recaptchalib.php');

    //  recaptchalib.php
    /* the reCAPTCH stuff is here, i took it out because it's too long for the forum*/

    $publickey "6Ld9cwIAAAAAAEZBAzRayp2tJLYScEt-rzJ2ZX7T"// you got this from the signup page
    echo recaptcha_get_html($publickey);
    ?>
    reCAPTCHA should be above.
    </td></tr>
    <tr><td></td><td><input type="button" value="Close" onclick="closeMessage()" /><input type="submit" value="Send" /></td></tr>
        
    </table>
    </form>
    </html>    
    <?
    }
    ###########################
    #######SWITCH BOARD########
    ###########################

    switch ($_SERVER['QUERY_STRING']) {
        case 
    'submitinfo':
            
    makeheader();
            
    submitinfo();
            
    makefooter();
            break;
        default:        
            if(
    $_SERVER['QUERY_STRING'] == 0){
                
    //$section='1';
                
    home();
                break;
            }
    }

  2. #2
    Join Date
    Mar 2011
    Posts
    1
    Here is a solution to have a working recaptcha in a popup window-

    http://www.skipser.toolsbysk.com/p/9...l?t=1299908329

    I am using this.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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



Recent Articles