One form, One submission button, but TWO actions

后端 未结 5 790
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-11 05:44

I have a form that collects client\'s info and then it

  • saves them in the database
  • sends out few emails
  • sends the info to SalesForce (SF) depar
5条回答
  •  忘掉有多难
    2020-12-11 06:16

    The only way to do this in client side is using AJAX.
    It is better to do SF stuff in server side (via DB if you have access or Web service if they have one or at least sending data via CURL at server side).
    it is possible one of submissions fail in client side (and it seems to be bad if second one fail - first request has no idea that scond one is not done properly).


    EDIT:
    Sample code for posting with CURL:
    assuming you have a form with a text and a hidden input:

    you can submit it using CURL like this:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,"http://your.sf.site/your_sf_submit_page.php");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,"field1=value1&field2=value2");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $server_output = curl_exec ($ch);
    curl_close ($ch);
    

    then you can check $server_output for being sure that form is submitted correctly.

提交回复
热议问题