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">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- 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//-->
          $publickey = "7LddU9wSAAAAAP4sidMIqpa2al3dz6KeEYmUCBvL"; // you got this from the signup page
          echo recaptcha_get_html($publickey);
        <!-- Captcha //-->
      <br /><br />
      <input type="submit" name="submit">

PHP Processing Page


$fields_string = '';
  require_once('recaptchalib.php');// download and put in the recaptcha folder 
          //Recaptcha Settings
    $publickey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; // you got this from the signup page

 //curl method posting
 //extract data from the post
   if ($submit){
   $ok = 1;
    $resp = recaptcha_check_answer ($privatekey,
    if (!$resp->is_valid) {
     $ok = 0;
  if ($ok){  
  //set POST variables
  $url = 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';
  $fields = array(



   //url-ify the data for the POST
  foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
   //open connection
  $ch = curl_init();
   //set the url, number of POST vars, POST data
  //execute post
  $result = curl_exec($ch);
  //close connection
 echo 'Congratulation the leads has been sent successfully.';
 } //if ok
 else {
     echo "<h4>Sorry - Invalid Captcha  Please try again  </h4>";
 } //if submit.
  • Just in case, have you set error_reporting to E_ALL | E_STRICT in php.ini? Is there anything in your error log? Jan 31, 2013 at 0:47
  • Are you getting any errors? What happens after the CAPTCHA validates? Do you get to your success page, stay on the initial URL, or something else?
    – Mike Chale
    Jan 31, 2013 at 12:15
  • @MikeChale Nope. No errors whatsoever, And yes it goes through to the success page but the lead does not show up in Salesforce
    – user988
    Jan 31, 2013 at 17:08
  • Have you triple checked the OID is your Org Id? What do you get if you add the debug parameter into the Web-to-Lead HTML? Feb 1, 2013 at 0:44
  • Any progress with this @user988? Feb 18, 2013 at 0:18

1 Answer 1


Curling Web-to-Lead has bitten me before via both funky character encodings and validation rules. Can you share the data you are testing with and I'll try?

Edit: I tried submitting to your Web-to-Lead code, complete with a unicode smiley face, substituting in my own oid and sans the CAPTCHA. The lead went in OK.

To eliminate one more variable from the equation, have you considered a GOTCHA field instead?

  • really? and strange. did you change anything?
    – user988
    Jan 31, 2013 at 0:27
  • 1
    Yessir. I changed the oid and commented out the CAPTCHA. Do you have any zealous validation rules on Lead or deduping packages (eg RingLead) in your org? Jan 31, 2013 at 0:33
  • No not that i know of. I've tried other ways without the captcha and it works but i want to see if this captcha work. for the life of me i can't get it to work with this
    – user988
    Jan 31, 2013 at 0:51
  • 1
    What do you get if you configure curl_setopt($ch, CURLOPT_RETURNTRANSFER, true), and do var_dump($result)? Jan 31, 2013 at 1:24
  • I know for me not populating the country would cause web2lead submissions to get dropped by SFDC. I think it was a 'Country Complete' module that was causing the issue.
    – creuzerm
    Jul 1, 2013 at 16:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .