2009-08-12 25 views
8

Sitemize bir reCAPTCHA eklemeye çalışıyorum, ama cevap verdiğimde incorrect-captcha-sol hata almaya devam ediyorum.reCAPTCHA ile yardıma ihtiyacım var - false captcha-sol

Aşağıdakileri yapmakta doğru olduğumu bana söyleyebilir mi?

Genel bir index.php'ye sahibim. ,

<form name="contactForm" method="post" action="index.php?id=contact&action=submit#contact"> 
    <tr><td>Name</td><td><div align="right"> 
     <input type="text" name="name_txt" class="input"> 
     </div></td></tr> 
    <tr><td>Email</td><td><div align="right"> 
     <input type="text" name="email_txt" class="input"> 
    </div></td></tr> 
    <tr><td height="10"></td></tr> 
    <tr><td colspan="2">Message</td></tr> 
    <tr><td colspan="2"><textarea name="message_txt" class="textarea" style="width:200px; height:100px"></textarea></td></tr> 
    <tr><td colspan="2"><?php echo recaptcha_get_html($publickey, $error); ?></td></tr> 
    <tr><td colspan="2" style="padding-top:10px;"><input type="image" src="images/header_06.gif" name="submit" value="submit"></td></tr> 
    </form> 

ben yanlış bir şey yapıyorum olduğunu göremiyorum: Benim html olarak

böyle CAPTCHA takılı

require_once('recaptchalib.php'); 
$publickey = "XXXX"; 
$privatekey = "XXXX"; 

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

if ($_POST['submit']) { 
    $message = $_POST['message_txt']; 
    $name = $_POST['name_txt']; 
    $email = $_POST['email_txt']; 

$emailBody = $message; 
$to = 'xx'; 
$from = $name.' <'.$email.'>'; 
$subject = 'XX Website Enquiry'; 
$headers = 'From: '.$from; 

$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); 

if ($resp->is_valid) { 
    echo 'captcha correct'; 
    if (mail($to,$subject,$emailBody,$headers)) { 
     //echo 'mail sent'; 
     $confirmation = 'sent'; 
    } 
    else { 
     //echo 'mail not sent'; 
     $confirmation = 'error'; 
    } 
} else { 
    # set the error code so that we can display it. You could also use 
    # die ("reCAPTCHA failed"), but using the error message is 
    # more user friendly 

    $error = $resp->error; 

    echo $error; 
} 

}: contact.php ben şu kodu ekledikten ama herhangi bir yapıcı eleştiri için minnettarım. TIA

cevap

19

, ben rastlamak en sıradışı şeylerden biridir dan, benim sözdizimi daha önce oldu:

<table> 
<form> 
<tr><td></td></tr> 
</form> 
</table> 

ben bunu değiştirdi Bu: aniden Çünkü bu anahtar

<form> 
<table> 
<tr><td></td></tr> 
</table> 
</form> 

, recaptcha_response_field ve recaptcha_challenge_field değerleri yeniden forma gönderir.

Bunun nedenini düşünemiyorum çünkü tüm form değişkenlerim geçişten önce geri gönderildiler.

İşaretçiler için teşekkürler.

7

iki kez onay gönderilirken eğer - örneğin bir kez javascript gelen ve bir kez ikinci bir API olarak başarısız olur php kullanarak yalnızca bir çözüm kez geçerli dönmek için izin verir. yardımcı olur

Umut, Josh

0

Eğer doğru bir deyişle yazdığınız emin misiniz?

bu bir bu çözmüş recaptcha website :

Line 1  "true" or "false". True if the reCAPTCHA was successful 
Line 2 if Line 1 is false, then this string will be an error code. reCAPTCHA can 
    display the error to the user (through the error parameter of api.recaptcha.net/challenge). 
    Implementations should not depend on error code names, 
as they may change in the future. 


    Example: If your response looks like this: 

    false 
    **incorrect-captcha-sol** 

    ... you can add '&error=incorrect-captcha-sol' to the challenge request URL, 
and the user will get an error code. 
5

Bunun nedeni, formun tr dışında olamayacağı ..... tablonun dışarıda olması gerekir ..... form tabloya eklenemez, ancak td'ye eklenebilir .

method = "POST"

Alkış: Benim durumumda

2

, hata belirtmeden formu ayarlamak oldu!

İlgili konular