Sales Force Web to Lead With Existing PHP File

questionmarkI'm working on a web-to-lead implementation. In a nutshell, the content submitted via an HTML form needs to auto-update a new instance of

I thought it would be straight forward after reading these website setup instructions but I can't get it to work. The issue I'm having is with my existing PHP file that drives the forms. the Web-to-Lead only updates SF when the form action is equal to When the form action is equal to my PHP file, it doesn't work!

Yes, I've already posted in the SF community forums, but I thought I'd try my luck here. Just in case...

Share this entry

Comments (10 - click here to join in!)


I am having the same problem. Can you help me out please.
Ihave a php form which inserts to mysql DB and also emails it out. To this, I added my salesforce input fields to post to salesforce using the action="" in the form. This posts to salesforce, but entirely skips the post to the sql database. All my code is in the same file. Please help

June 1, 2009 @ 3:23 PM

Toronto Mike

In the PHP:

// =======================================
// =======================================
define('OID', '123456789');
define('SF_URL', '');

$ch = curl_init(SF_URL);
$data = $_POST;

$data['oid'] = OID;
$data['sfga'] = '';
$data['123456789'] = $_SERVER['REMOTE_ADDR'];

foreach($data as &$item) {
$item = stripslashes($item);

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

$result = curl_exec($ch);
if( $result === false ) {
echo 'Error: '.curl_error($ch).PHP_EOL;
// =======================================
// =======================================

June 1, 2009 @ 3:29 PM



I'm new to this salesforce thing myself.

I'm trying to figure out how to NOT utilize the retURL field.

I'd ultimately like to just post the form to salesforce without redirecting.

Is this possible? If I leave out a value for retURL it just reloads the page. Would rather it not do anything.


October 7, 2009 @ 4:42 PM

Toronto Mike Verified as the defacto Toronto Mike

Can you self reference the page - so the retURL is the URL of the form itslef?

October 7, 2009 @ 5:06 PM


nevermind...just take out the hidden field!

October 7, 2009 @ 5:06 PM


Toronto Mike,
I am trying to setup a php script to submit fields for the web-to-lead function from Salesforce as well. I am not a web developer but can hack some things together as needed. I see your sample of the php setup you used but am not sure where it references items like:
input id="first_name"
input id="title"
input id="last_name"


Any help would be much appreciated.


December 1, 2009 @ 4:48 PM

Mike Vardy

$data = $_POST;

July 21, 2010 @ 10:54 PM

Leave a comment

Only 10 comments? C'mon, we can do better... Leave a comment above and let's keep this conversation going!

« Cocaine Looks and Sounds Awesome Game Two Tonight »