0

I have a form in my website(Example : Application for applying the Job).when the user fill the form in our website and submits.A record should be created in the custom object.

  • what language you are using for your website? – Himanshu Nov 17 '15 at 18:01
  • yes. we are using PHP language for our website – Donald Nov 17 '15 at 18:03
1

Salesforce provides PHP SDK which can be used to interact with Salesforce from your PHP application.

  1. Download PHP SDK
  2. Put SOAPClient in your root folder.
  3. Download partner.wsdl.xml from your Salesforce setup-> Develop -> API and put that in root folder as well.
  4. Create new PHP file create.php and copy following code.
  5. replace UserName and password value with your credentials.
  6. Pass your form values to this file

Sample code:

<?php
require_once ('soapclient/SforcePartnerClient.php');    
try {
       $USERNAME='YOURSFDCUSERNAME';
       $PASSWORD ='YOURSALESFORCEPASSWORD+SECURITYTOKEN';
       $mySforceConnection = new SforcePartnerClient();
       $mySoapClient = $mySforceConnection->createConnection('partner.wsdl.xml');
       $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);

  $fields = array (
    'FirstName' => 'John',
    'LastName' => 'Smith',
    'Phone' => '510-555-5555',
    'BirthDate' => '1950-01-01'
  );

  $sObject = new SObject();
  $sObject->fields = $fields;
  $sObject->type = 'Contact';

  echo "**** Creating the following:\r\n";
  $createResponse = $mySforceConnection->create(array($sObject));

  print_r($createResponse);


} catch (Exception $e) {
  echo $mySforceConnection->getLastRequest();
  echo $e->faultstring;
}
?>

You can go through other sample code here

Salesforce PHP SDK samples

  • Hi Himanshu, i have downloaded the PHP SDK Tool kit from the salesforce .what would be the next step to take .As i am new to this development and i dont know PHP. Can you please give me the detailed instructions .Thank you – Donald Nov 17 '15 at 18:15
  • i have updated question with instruction but as you don't know PHP it can be hard for you to understand because it need some knowledge of PHP. you can contact your php developer to complete this task – Himanshu Nov 17 '15 at 18:33
  • we don't have a PHP Developer Himanshu.... – Donald Nov 17 '15 at 21:26
  • Hi Himanshu, I have an Php form ...Lets say First Name,Last name and there are around 20 fields on the application from.when the users fills the values in the form and clicks submit. How to pass the values to the Php code (Above) so that it creates the record in salesforce with all those values – Donald Nov 19 '15 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.