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

Web To Lead in PHP Form

Greetings, I need your help,


I have two forms set up on a website. They are both the same form the difference being that one is in PHP and does not have Web To Lead implemented into it (I wish it did). The other is a working form that I made with Web To Lead without PHP. I will explain my goals as you read on.



I am not a PHP coder so I'm clueless in this area. I have a PHP form on a website that works beautifly. It has terriffic spam protection, I can easily tell it which fields need to be required and was real easy to set up:


The PHP it uses is called Form To Email Pro You can DL a free version on their website (left side of page), pro version is not much different.


I really like this form because it was so easy for code challenged people like myself to setup. It would be great if I could some how implement the fields necessary to get Web To Lead to work. Can someone help me with this or is it impossible?



I also made a non php version using Web To Lead that IS working but I need to tell the form which areas are Required. Apparently, I can set these fields in my SalesForce account but it also has to be done at the form as well. How is this done. Here is a link to the SalesForce enhanced version:


Thank you for looking at this, I hope someone can help me out. Bottom line, I am trying to have a form that will guard against spam as well as the PHP version does and can be set up with Required fields.


Scott Hemmeter has the solution that you are looking for >



That should work for what you need




Hi Mike,


Thanks for the link. It looks like that solution is for WordPress users but I have submitted a question to them about it. What about making fields "requirered"? It looks like I will have to ust the HTML version of my form and not the PHP version for this to work so how do I make the fields I created through web to lead required within the form?


well that addon is not for word press users, it is a script that handles web to leads. You should be able to customize it or use javascript form validation >





Thanks Mike,


I'll check it out.




You can have intermediate PHP page which will collect all field values and send/post using SOAP to SalesForce.

Salesforce web service API have php toolkit. 





Good version of php form, I know good php form too.

Bruno Bonfim AffonsoBruno Bonfim Affonso
Use cURL, it's simple. Don't forget to change the URL.
//url - test
$url = '';

//your POST data
$fields = array('first_name'=>urlencode('Test'),
    'company'=>urlencode('Test Inc.'),
    'phone'=>urlencode('+55 41 0000-0000'),
    'recordType' =>urlencode(''),
    'oid' => '',
    'retURL' => urlencode('/'));

$fields_string = '';

//url-ify the data for the POST
foreach($fields as $key => $value) {
    $fields_string .= $key.'='.$value.'&';

$fields_string = rtrim($fields_string,'&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data


//execute post
$result = curl_exec($ch);

//close connection