<form action="" method="post"> <?PHP require_once('recaptchalib.PHP'); // Get a key from https://www.google.com/recaptcha/admin/create $publickey = "你的公共key ---自己去http://www.google.com/recaptcha申请"; $privatekey = "你的私有key ---自己去http://www.google.com/recaptcha申请"; # 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 $error; //echo $_POST["recaptcha_challenge_field"]; //echo $_POST["recaptcha_response_field"]; } } echo recaptcha_get_html($publickey,$error); ?>