2009-08-12 13 views
8

प्राप्त करना जारी रखें मैं अपनी साइट पर एक reCAPTCHA जोड़ने की कोशिश कर रहा हूं, लेकिन जब मैं उत्तर सबमिट करता हूं तो incorrect-captcha-sol त्रुटि प्राप्त करना जारी रखें।reCAPTCHA के साथ मदद की ज़रूरत है - गलत-कैप्चा-सोल

क्या कोई मुझे बता सकता है कि क्या मैं निम्नलिखित करने में सही हूं?

मेरे पास एक सामान्य index.php है, जिसमें contact.php शामिल है। contact.php में मैं निम्नलिखित कोड डाला है:

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; 
} 

}

मेरी एचटीएमएल में मैं इस तरह कॅप्चा डाला:

<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> 

मैं नहीं देख सकता हूँ कि मैंने कुछ गलत कर रहा हूँ, लेकिन किसी भी रचनात्मक आलोचना की सराहना करेंगे।

TIA

उत्तर

19

मैं इस समाधान कर लिया है, यह सबसे असामान्य चीजें मैं भर में आ गए हैं में से एक है, मेरे वाक्य रचना पहले से था:

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

मैं इसे करने के लिए बदल यह:

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

इस स्विच के कारण, अचानक recaptcha_response_field और recaptcha_challenge_field मूल्यों को वापस फॉर्म पर पोस्ट कर रहे हैं।

मुझे नहीं लगता कि ऐसा क्यों है क्योंकि सभी मेरे फॉर्म चर स्विच से पहले वापस पोस्ट किए गए थे।

पॉइंटर्स के लिए सभी को धन्यवाद।

7

आप चेक दो बार पोस्ट कर रहे हैं, तो - जैसे एक बार जावास्क्रिप्ट से और एक बार php दूसरा एक एपीआई के रूप में असफल हो जायेगी के माध्यम से केवल एक समाधान एक बार मान्य वापस जाने के लिए अनुमति देता है।

आशा है कि मदद करता है, जोश

0

क्या आप वाकई सही शब्दों में लिख रहे हैं कर रहे हैं?

इस एक से 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

ऐसा इसलिए है क्योंकि यह फॉर्म tr के बाहर नहीं हो सकता है ..... इसे तालिका के बाहर की ओर होना चाहिए ..... फॉर्म को तालिका में सम्मिलित नहीं किया जा सकता है, इसे टीडी में डाला जा सकता है हालांकि ।

विधि = "पोस्ट"

चीयर्स:

2

मेरे मामले में, त्रुटि निर्दिष्ट किए बिना सेट कर गया था!

संबंधित मुद्दे