2013-08-01 08:48 阅读 51


I currently have a clients landing page set up so that it posts any new signups to Salesforce. The information primarily goes through to my own system which requires specific form field id's. Salesforce also requires specific form field id's. To do this I have created a second set of form fields that are hidden, and I'm using javascript to set the value of the hidden fields to the same as the visible ones. The only problem with this is that if javascript isn't enabled on the end-users browser, then most of the information doesn't go through to Salesforce.

Is there an alternative way of doing this in PHP? I'm not an expert with PHP, and my thinking was to post the data to an interrupt page, echo the value of the visible fields in the hidden fields, and then use a header redirect to go to the normal script.

Any suggestions would be greatly appreciated

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    duangang4940 duangang4940 2013-08-01 11:07

    I wont show you the form as I'm aware you already have one set up

    But here is how I would approach this using cURL

    $url = '';
    $post_data = "first_name={$_POST['fname']}&last_name={$_POST['lname']}&email={$_POST['email']}&phone={$_POST['telephone']}&country={$_POST['country']}&description={$_POST['comments']}";
    $ch = curl_init( $url );
    curl_setopt( $ch, CURLOPT_POST, 1);
    curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt( $ch, CURLOPT_HEADER, 0);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec( $ch );
    点赞 评论 复制链接分享
  • doujingtang6580 doujingtang6580 2013-08-01 08:53

    If you want to avoid having to rely on anything front-end like JavaScript, then cURL is going to be your best bet. With this, you would eliminate the hidden fields. When the user submits the form, your PHP script would gather the information, repackage it for SalesForce, and then POST it to their form script as if entering it directly into their form. This also means that your server is doing the POST rather than the user's browser, so the interaction with SalesForce ends up being completely transparent to the user.

    点赞 评论 复制链接分享