Reply
Newbie
Jayreis
Posts: 1
0

Issue with php web form to salesforce.com insert

I am using the php code here

http://www.paulwest.co.uk/article.php/salesforce-form-integration-with-php

 

to be able to take the data submitted on a contact form and insert it into my clients salesforce acct.

My issue is the website url field is not being inserted into sales force and and I am thinking maybe I need to do something like urlencode() the website url $var but thats not working? 

 

advice? Thanks

My code

 

[code]

 

//set POST variables
$url = 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';

$cleanPOST = array();
$cleanPOST['first_name']= "$fname";
$cleanPOST['last_name']= "$lname";
$cleanPOST['phone']="$phone";
$cleanPOST['email']="$visitor_email";
$cleanPOST['street']="$address";
$cleanPOST['city']="$city";
$cleanPOST['state']="$state";
$cleanPOST['zip']="$zip";
$cleanPOST['company']="$business";
$cleanPOST['phone']="$phone";
$cleanPOST['lead_source']="Web";
$cleanPOST['description']="$message";
$cleanPOST['title']="$title";
$cleanPOST['website']= urlencode("$website");
$cleanPOST['mobile']="$mobilephone";


// Loop through the $_POST data and process it
foreach ($_POST as $key=>$value){
$cleanPOST[stripslashes($key)] = stripslashes($value);
}

// Add the Org ID
$cleanPOST["oid"] = '##########'; 

//open connection
$ch = curl_init($url);

// Point to the Salesforce Web to Lead page
curl_setopt($ch, CURLOPT_URL, "http://www.salesforce.com/servlet/servlet.WebToLead");

// Set the method to POST
curl_setopt($ch, CURLOPT_POST, 1);

// Pass POST data
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($cleanPOST));

curl_exec($ch); // Post to Salesforce
curl_close($ch); // close cURL resource

[/code]