2011-07-26 7 views
1

ajax와 함께 recaptcha의 유효성을 검사하려고 시도 할 때 유일한 문제는 recapthca가 잘못 입력되었다는 것입니다. 내 코드가 무엇이 잘못되었는지 궁금합니다. 양식 페이지에 ajax 유효성 확인 recaptcha에 대한 오류

<?php 
    require_once('recaptcha/recaptchalib.php'); 
    define("PUBLICKEY"," "); 
    define("PRIVATEKEY"," "); 

    $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); 
    if ($resp->is_valid) { 
    ?>success<? 
     $name = $_POST['name']; 
     $email = $_POST['email']; 
     $phone = $_POST['phone']; 
     $reason = $_POST['reason']; 
     $header = 'From: ' . $email . " \r\n"; 
     $msg = "Sent from: " . $name . "\r\n"; 
     $msg .= "Email: " . $email . " \r\n"; 
     $msg .= "Phone: " . $phone . " \r\n"; 
     $msg .= "Contact reason:" . $reason . " \r\n"; 
     $msg .= "Message: " . $_POST['message'] . " \r\n"; 
     $msg .= "Date and time " . date('d/m/Y', time()); 

     $to = ''; 
     $subject = 'contact page'; 

     mail($to, $subject, utf8_decode($msg), $header); 
    } 
    else 
    { 
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . 
     "(reCAPTCHA said: " . $resp->error . ")"); 
    } 
?> 

나는이

<?php 
    require_once('recaptcha/recaptchalib.php'); 
    define("PUBLICKEY",""); 
    define("PRIVATEKEY"," "); 
?> 

<div id="contact-form"> 
<?php echo $content; ?> 
     <form action="#" method="POST" id="contactForm" onSubmit="return validateCaptcha()"> 
    <div class="form"> 
      <label for="name">Your Name: <span class="requireds">(Required)</span><br /></label> 
      <input id="name" name="name" class="text-input" minlength="2" /> 
    </div> 
    <div class="form"> 
      <label for="email">Your Email:<span class="requireds">(Required)</span><br /></label> 
      <input id="email" name="email" class=" text-input" /> 
    </div> 
    <div class="form"> 
      <label for="phone">Your Phone:<br /></label> 
      <input id="phone" name="phone" type="text" maxlength="200" class="text-input" /> 
    </div> 
    <div class="form"> 
      <label for="reason">Contact reason:<br /></label> 
      <select id="reason" name="reason" class="select"> 
       <option>Sales question </option> 
       <option>Time/ Delivery</option> 
       <option>My existing Order</option> 
       <option>Technical Question</option> 
       <option>Revision/ Support</option> 
       <option>Other</option> 

      </select> 
    </div> 
    <div class="form"> 
      <label for="message">Message: <span class="requireds">(Required)</span> <br /></label> 
      <textarea id="message" name="message" class="textarea"></textarea> 
    </div> 

    <div style="margin:10px 0; width:495px; -moz-border-radius:3px; border-radius:3px;"> 
       <p style="color: #f14444; text-align:right; font-size:12px" id="captchaStatus">&nbsp;</p> 
        <?php echo recaptcha_get_html(PUBLICKEY); ?> 

     </div> 
     <input type="submit" value="" class="send"/> 

    </form> 

내가 이미 공개 키와 개인 키가 올바른지 .. 누군가가이 코드에 어떤 문제가 있는지에 대한 아이디어가 않습니다 확인 있나요?

+0

어떤 HTML이 생성됩니까? –

+0

무엇을 의미합니까? 미안하지만 영어 수준이 매우 낮습니다! 내가 페이지를 테스트 할 때 무엇이 ​​잘못 되었는가? – karlelizabeth

+0

브라우저에서 양식 페이지를 볼 때 소스를보고 그 내용을 말해주십시오 –

답변

0
API 키가 제대로 제출되지 않는 것을 저에게 알려주는 reCAPTCHA를 제출할 때이 오류를 받고

:

당신이 https://www.google에서 API 키를 받아야합니다 reCAPTCHA를을 사용하기를. COM/reCAPTCHA를/관리/생성

업데이트 :

recaptcha_check_answer ($privatekey,

문제가 있습니까? PRIVATEKEY 대신 $privatekey을 사용하고 있으므로 실제로 비공개 키를 제출하지 않습니다. 오류가 정확했습니다 (오류 메시지를 신뢰하십시오!). Chrome의 기본 제공 개발자 도구 (Ctrl + Shift + i)를 사용하여이를 디버깅합니다.

+0

recpatcha 키가 좋습니다! 나는 정말로 무엇이 있는지에 관해 모른다. 그러나 열쇠는 ok 다! – karlelizabeth

+0

대단히 감사합니다! 네가 옳았다 ... 많이 고마워! – karlelizabeth

관련 문제