
Untitled
By: a guest on
Jul 24th, 2012 | syntax:
PHP | size: 1.27 KB | hits: 15 | expires: Never
require_once("recaptchalib.php");
$privatekey = "--your private key--";
if (isset($_POST['submit'])) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
$error = "The reCAPTCHA wasn't entered correctly. Please try it again." . "(reCAPTCHA said: " . $resp->error . ")";
} else {
// Valid captcha entry, proceed to submit to salesforce
/* This code passes all get and post variables to salesforce for logging, since captcha has been verified */
$ch = curl_init('https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8');
$encoded = '';
// include GET as well as POST variables; your needs may vary.
foreach($_GET as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
foreach($_POST as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
// chop off last ampersand
$encoded = substr($encoded, 0, strlen($encoded)-1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
curl_close($ch);
}
}