Good Morning Ladies and Gents,

I am having the following issue. I have implemented a captcha widget to my downloads page since there were a log of spam files that were coming through. After hours of working on this I have finally gotten the Captcha app to work and forward after successful entry to the actual download page.

However, the lead info that was inputted in the form is not being forwarded as a lead at all. My guess is that the code is missing in the verify.php file. But I am not entirely too sure. Might have taken on a bit too much of a project with this one.


<form action="verify.php" method="POST">
<input type=hidden name="oid" value="SALESFORCE I.D.">
<input type=hidden name="retURL" value="/downloads.php">
  <label for="first_name"><br />
    <strong>(*) Fields that are required </strong><br />
    <br />
    First Name (*)</label><br />
  <input  id="first_name" maxlength="40" name="first_name" size="20" type="text" required="required" /><br>

  <label for="last_name">Last Name (*)</label> <br />
  <input  id="last_name" maxlength="80" name="last_name" size="20" type="text" required="required"  /><br>

  <label for="email">Email (*)<br />
  <input  id="email" maxlength="80" name="email" size="20" type="text" required="required" /><br>

  <label for="phone">Phone <br />
  <input  id="phone" maxlength="40" name="phone" size="20" type="text" /><br>

  <label for="company">Company <br />
  <input  id="company" maxlength="40" name="company" size="20" type="text" /><br>

  <label for="city">City <br />
  <input  id="city" maxlength="40" name="city" size="20" type="text" /><br>

  <label for="state">State/Province <br />
  <input  id="state" maxlength="20" name="state" size="20" type="text" /><br>

  <label for="country">Country <br />
  <input  id="country" maxlength="40" name="country" size="20" type="text" /><br><br>
  <strong>Interest (hold Ctrl (Windows) / Command (MacOsX) to select more than one)</strong></p>
<select  id="SALESFORCE_ID" multiple="multiple" name="SALESFOCE_NAME" title="Interest"><br>
<option value="C5">C5</option>
<option value="D5">D5</option>
<option value="Dispensing">Dispensing</option>
<option value="In-Line">In-Line</option>
<option value="M7">M7</option>
<option value="M75">M75</option>
<option value="M7 HP">M7 HP</option>
<option value="M8 Cube">M8 Cube</option>
<option value="M8">M8</option>
<option value="M85">M85</option>
<option value="M10 Pro">M10 Pro</option>
<option value="M10 Power">M10 Power</option>
<option value="ML">ML</option>
<option value="MXL">MXL</option>
<label for="lead_source"></label>
<input id="lead_source" maxlength="40" name="lead_source" size="20" option value="Web Form" type=hidden />
    $publickey = "PUBLIC_GOOGLE_cAPTCHA_kEY";
    echo recaptcha_get_html($publickey);
<input type="submit"/>
</form><p> </p>


 $resp = recaptcha_check_answer ($privatekey,
 if (!$resp->is_valid) {
   // What happens when the CAPTCHA was entered incorrectly
   die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
        "(reCAPTCHA said: " . $resp->error . ")");
 else {
   // Your code here to handle a successful verification
   echo '<META HTTP-EQUIV="Refresh" Content="0; URL=downloads.php">';
//    header("Location:");
//    $url = '';

In the above coding the last two lines:

// $url = '';

Are my guess as to where I should be pointing the forward. However, I thoroughly believe that I am missing something else as I feel as though the SF ID and user name are missing.

Certain values have been replaced due to security reasons. Please let me know if you could further assist with the following to make sure that I can get this thing going as every other hour or so I am getting some spam message from China,

Thank you.


You cannot redirect the user to one page, whilst still submitting the form details to Sales Force in the manner you're trying.

I did something similar a few months back and chose to use cURL to post the form values directly to Sales Force.

I've taken the code from an Enquiry class I wrote and packaged it up in a function.

 * Capture web lead in Sales Force CRM.
 * @param array $data
 * @return boolean
function capture_lead(array $data)
    // Prepare request URL
    $url = '';

    // Prepare lead
    $lead = array(
        'oid'         => 'XXXXXX',
        //'debug'       => 1,
        //'debugEmail'  => $data['recipient'],
        'first_name'  => $data['first_name'],
        'last_name'   => $data['last_name'],
        'title'       => $data['job_title'],
        'company'     => $data['company'],
        'email'       => $data['email'],
        'phone'       => $data['phone'],
        'country'     => $data['country'],
        'description' => $data['description'],
        'lead_source' => 'Web',
        'retURL'      => '',

    // Initialise new cURL session and set cURL options
    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_URL            => $url,
        CURLOPT_HEADER         => false,
        CURLOPT_POST           => true,
        CURLOPT_TIMEOUT        => 5,
        CURLOPT_POSTFIELDS     => http_build_query($lead),
        CURLOPT_SSL_VERIFYPEER => false,

    // Store cURL session response
    $response = (bool) curl_exec($curl);

    // Check that no error was returned
    if(false <> curl_error($curl))
        $response = false;

    // Close cURL session
    return $response;

Hope this helps.

Would this be an insert in the form.php file or the verify.php file?

I might be asking a lot here but if possible I would have to ask for the coding in the correct spot for just a copy and paste. This truely isnt my fortay :/

Initially the inquiry was just an implementation of Saleforce which I completed. Then the REQ for Salesforce Web2Lead came in and thats when I got flustered with this entire scenario.

Other thought I had was possible running another php from the verify to input the info into Salesforce. But my guess is that wouldnt work out either correct?

Would this cURL have a captcha involved to handle the spam issue or is that not the case here?

You would add the function to verify.php and call the function, capture_lead($_POST) on line 14 before you redirect to download.php.

You would then need to update the lead array within the function so that the array keys and corresponding data indexes match the SalesForce fields you wish to populate and your form field names sync up accordingly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.