function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Posting to servlet.WebToLead from PHP : anyone got it working'


I'm trying to POST to WebToLead service through the servlet however I do not seem to beable to get the thing to work. The HTML generated from works fine, then I would presume posting the same information as in the form to would also work but no leads are generated in

Has anyone got this to work from PHP? Has anyone got some working example code?

p.s. I do not want to use the API.

Thanks for your time


Couple of possibilities:

1. You are checking for the new Lead too soon.  It takes a few seconds to show, sometimes minutes.

2. Make sure all those *hidden* fields are being passed too.  Especially OID.



require_once "HTTP/Request.php";
$req =& new HTTP_Request("–encoding=UTF-8");
$msg = "";
foreach($_REQUEST as $InputName => $InputValue)
  $msg .= $InputName . " = " . $InputValue . " \n";
$response = $req-> sendRequest();
if (PEAR::isError($response)) {
      $msg .= "Error: " . $response->getMessage() . "\n" . 
     mail('','Failed Web-to-Lead',$msg);
$code = $req->getResponseCode();
// echo $code, "\n";

Here's a sample which generates a post to the servlet.

It's called from a modified version of the salesforce generated form. The generated form is changed to post all the same data to this php routine, which then re-posts it to salesforce.


Hi there,

this looks really interesting - please could you tell me what is in the include in line 2, and I'm struggling a bit with a task very similar to this!