douqiong8412 2013-08-01 08:48
浏览 51
已采纳

你如何使用PHP来复制表单字段?

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 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 = 'http://salesforceurl.here';
    $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 );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog