I want to make a simple web-to-lead form with recaptcha to validate it. i followed these instructions : Captcha Tutorial with Curl and it compiles and the captcha appears to be validating the form but the lead is not being posted to Salesforce for some reason. Has anyone ever implemented anything similar? Any ideas? Thanks
Web To Lead HTML Form
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form</title>
</head>
<body>
<!-- Your form must be put instead of this form and put the bold parts in that form -->
<form action="check-this-first.php" method="post" name="emailForm" id="test" style="padding: 0px; margin: 0px;" >
<input type=hidden name="oid" value="00F600000000000">
<input type=hidden name="retURL" value="http://www.yahoo.com">
<label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>
<label for="last_name">Last Name</label><input id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>
<label for="email">Email</label><input id="email" maxlength="80" name="email" size="20" type="text" /><br>
<label for="company">Company</label><input id="company" maxlength="40" name="company" size="20" type="text" /><br>
<label for="phone">Phone</label><input id="phone" maxlength="40" name="phone" size="20" type="text" /><br>
<td align="left" >
<span class="style1 style2">Verify Code:<br />
<br />
<!-- Captcha//-->
<?php
require_once('recaptchalib.php');
$publickey = "7LddU9wSAAAAAP4sidMIqpa2al3dz6KeEYmUCBvL"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
<!-- Captcha //-->
</td>
</tr>
<tr>
<td>
<br /><br />
<input type="submit" name="submit">
</td>
</tr>
</table>
</form>
</body>
</html>
PHP Processing Page
<?php
session_start();
ob_start();
$fields_string = '';
require_once('recaptchalib.php');// download and put in the recaptcha folder
//Recaptcha Settings
$publickey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; // you got this from the signup page
$privatekey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";//your private key
//curl method posting
//extract data from the post
extract($_POST);
if ($submit){
$ok = 1;
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$ok = 0;
}
if ($ok){
//set POST variables
$url = 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';
$fields = array(
'oid'=>urlencode($oid),
'retURL'=>urlencode($retURL),
'first_name'=>urlencode($first_name),
'last_name'=>urlencode($last_name),
'email'=>urlencode($email),
'company'=>urlencode($company),
'phone'=>urlencode($phone),
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');
//print_r($fields_string);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
echo 'Congratulation the leads has been sent successfully.';
} //if ok
else {
echo "<h4>Sorry - Invalid Captcha Please try again </h4>";
}
} //if submit.
?>
error_reporting
toE_ALL | E_STRICT
inphp.ini
? Is there anything in your error log?