+ Start a Discussion
FlashmanFlashman 

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.

 

PHP VERSION

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:

 

http://www.regallimousine.com/reservation.htm

 

The PHP it uses is called Form To Email Pro http://formtoemail.com/ 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?

 

NON PHP VERSION

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:

 

http://www.regallimousine.com/reservation-sf.htm

 

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.

msimondsmsimonds

Scott Hemmeter has the solution that you are looking for > http://sfdc.arrowpointe.com/2007/05/24/fight-web-to-lead-spam-w-akismet/

 

 

That should work for what you need

 

~Mike 

FlashmanFlashman

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?

msimondsmsimonds

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 > http://www.javascript-coder.com/html-form/javascript-form-validation.phtml

 

 

~Mike 

FlashmanFlashman

Thanks Mike,

 

I'll check it out.

GaneshDGaneshD

Hi,

 

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. 

 

Regards

Ganesh

PolinaPolina

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 = 'https://test.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';

//your POST data
$fields = array('first_name'=>urlencode('Test'),
    'last_name'=>urlencode('Test'),
    'company'=>urlencode('Test Inc.'),
    'description'=>urlencode('Test'),
    '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
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);

curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, TRUE);

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

//close connection
curl_close($ch);