首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Formidable form -$ Post挂钩不起作用

Formidable form -$ Post挂钩不起作用
EN

Stack Overflow用户
提问于 2016-06-28 17:29:53
回答 1查看 654关注 0票数 1

嗨,我希望得到一个强大的专业网页表单发送数据到我的客户关系管理系统后,提交按钮被剪辑

我有90%的编码,但由于某些原因,它只是没有通过发送信息

我已经使用wordpress的代码片段插件将它添加到我的网站上,并设置代码片段,以便当表单x提交时,它应该通过crm系统发布各种数据

来自强大的pro表单的数据以以下格式输出21或18等我已经从数据周围删除了这组括号-因为格式中已经有一组brackets[]

附加的开发人员指南和示例代码从crm系统和我自己的90%开发的代码,有任何想法,为什么它不连接?

我的代码

代码语言:javascript
复制
add_action('frm_after_create_entry', 'yourfunctionname', 30, 2);
function yourfunctionname($entry_id, $form_id){
 if($form_id == 2){ //replace 5 with the id of the form

            //set POST variables
            $url = 'https://secure4.mortgagekeeperonline.co.uk/mywebsitelink/php/NewMortgageQuickDetails.php'; // Your system URL
            $fields = array(
                'StagePK'=>urlencode(25), // Must set Stage
                'AdvisorPK'=>urlencode(1), //Must set Adviser
                'MortgageMode'=>urlencode(0), // 'CommercialMode'=>urlencode(1), [IF CommercialKeeper}

                //Commercial Deatils
                'CompanyName'=>urlencode($_POST['companyName']),
                'ComAddressLine1'=>urlencode($_POST['companyAddressLine1']),
                'ComAddressLine2'=>urlencode($_POST['companyAddressLine2']),
                'ComAddressLine3'=>urlencode($_POST['companyAddressLine3']),
                'ComPostcode'=>urlencode($_POST['companyPostcode']),
                'ComTelephone'=>urlencode($_POST['Office']),
                'ComEmail'=>urlencode($_POST['Email']),
                'LegalStatus'=>urlencode(3),

                //Mortgage Details
                'LenderPK'=>urlencode(1),
                'InterestRateTypePK'=>urlencode(2),
                'Rate'=>urlencode(3.45),
                'DealTerm'=>urlencode(5),
                'Term'=>urlencode(25),
                'ActionPK'=>urlencode(11),
                'ActionText'=>urlencode($_POST['Notes']),

                //Applicant Details
                'Title1'=>urlencode($_POST['10']),
                'Forename1'=>urlencode($_POST['9']),
                'Surname1'=>urlencode($_POST['15']),
                'Email'=>urlencode($_POST['149']),
                'DayPhone'=>urlencode($_POST['28']),
                'MobilePhone'=>urlencode($_POST['29']),
                'Title2'=>urlencode($_POST['12']),
                'Forename2'=>urlencode($_POST['11']),
                'Surname2'=>urlencode($_POST['16']),
                'MidNameApp1'=>urlencode($_POST['13']),
                'MidNameApp2'=>urlencode($_POST['14']),


                //Fact Find Questions   
                'FFVersionPK12'=>urlencode(5), //Must set which FactFind    

                    'FFQuestionPK[1]'=>11884,
                    'FFAnswer[1]'=>urlencode($_POST['23']),  // looking to

                    'FFQuestionPK[2]'=>11885,
                    'FFAnswer[2]'=>urlencode($_POST['24']),  // credit history

                    // Just increment the FFQuestionPK and FFAnswer numbers in the square brackets by 1
                    // Replace the ???? in 'FFQuestionPK[3]'=>????, with the FactFind Question PK number
                    // and replace the ??? in 'FFAnswer[3]'=>urlencode($_POST['????']), with your form post value

                    'FFQuestionPK[3]'=>11463,
                    'FFAnswer[3]'=>urlencode($_POST['43']),  // property value

                    'FFQuestionPK[4]'=>9164,
                    'FFAnswer[4]'=>urlencode($_POST['57']),  // existing loans summary

                    'FFQuestionPK[5]'=>11466,
                    'FFAnswer[5]'=>urlencode($_POST['71']),  // term of mortgage

                    'FFQuestionPK[6]'=>11465,
                    'FFAnswer[6]'=>urlencode($_POST['44']),  // mortgage required

                    'FFQuestionPK[7]'=>8829,
                    'FFAnswer[7]'=>urlencode($_POST['17']),  // app1 DOB

                    'FFQuestionPK[8]'=>9772,
                    'FFAnswer[8]'=>urlencode($_POST['18']),  // app2 dob

                    'FFQuestionPK[9]'=>11886,
                    'FFAnswer[9]'=>urlencode($_POST['19']),  // app1 nationality




                'submit'=>true //Do not remove
                    );

            //url-ify the data for the POST
            foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
            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_RETURNTRANSFER,true);

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

            //Debug
            //var_dump($result);
            //var_dump(curl_getinfo($ch));

            //Generate eMail (If Required)
            $name1 = $_POST['Forename'];
            $name2 = $_POST['Surname'];
            $phone = $_POST['Office'];
            $email = $_POST['Email'];
            $comments = $_POST['companyName'];

            $message = "*** This is a message sent from the website contact form ***\r\n\r\n";
            $message .= "Contact Name: $name1 $name2\r\n";
            $message .= "Contact Number: $phone\r\n";
            $message .= "Email: $email\r\n";
            $message .= "Business: $comments\r\n\r\n------------ END -------------";

            if(mail('info@DOMAIN.co.uk', 'Website Contact Form', $message, "From: YOU@DOMAIN.co.uk\r\n")) {
                $emailStatus = 'Form Sent.';
            }else{
                $emailStatus = 'Form Not Sent. Please contact NAME on TELEPHONE.';
            }

            //close connection
            curl_close($ch);
        }
    }


==end code==

the developers example code was 

<?php

            //set POST variables
            $url = 'https://secure.mortgagekeeperonline.co.uk/SITENAME/php/NewMortgageQuickDetails.php'; // Your system URL
            $fields = array(
                'StagePK'=>urlencode(1), // Must set Stage
                'AdvisorPK'=>urlencode(4), //Must set Adviser
                'MortgageMode'=>urlencode(1), // 'CommercialMode'=>urlencode(1), [IF CommercialKeeper}

                //Commercial Deatils
                'CompanyName'=>urlencode($_POST['companyName']),
                'ComAddressLine1'=>urlencode($_POST['companyAddressLine1']),
                'ComAddressLine2'=>urlencode($_POST['companyAddressLine2']),
                'ComAddressLine3'=>urlencode($_POST['companyAddressLine3']),
                'ComPostcode'=>urlencode($_POST['companyPostcode']),
                'ComTelephone'=>urlencode($_POST['Office']),
                'ComEmail'=>urlencode($_POST['Email']),
                'LegalStatus'=>urlencode(3),

                //Mortgage Details
                'LenderPK'=>urlencode(1),
                'InterestRateTypePK'=>urlencode(2),
                'Rate'=>urlencode(3.45),
                'DealTerm'=>urlencode(5),
                'Term'=>urlencode(25),
                'ActionPK'=>urlencode(11),
                'ActionText'=>urlencode($_POST['Notes']),

                //Applicant Details
                'Title1'=>urlencode($_POST['Title']),
                'Forename1'=>urlencode($_POST['Forename']),
                'Surname1'=>urlencode($_POST['Surname']),
                'Email'=>urlencode($_POST['Email']),
                'DayPhone'=>urlencode($_POST['Office']),
                'MobilePhone'=>urlencode($_POST['Mobile']),

                //Fact Find Questions   
                'FFVersionPK'=>urlencode(5), //Must set which FactFind  

                    'FFQuestionPK[1]'=>11604,
                    'FFAnswer[1]'=>urlencode($_POST['datemoved1']),

                    'FFQuestionPK[2]'=>11636,
                    'FFAnswer[2]'=>urlencode($_POST['basic1']),

                    // Just increment the FFQuestionPK and FFAnswer numbers in the square brackets by 1
                    // Replace the ???? in 'FFQuestionPK[3]'=>????, with the FactFind Question PK number
                    // and replace the ??? in 'FFAnswer[3]'=>urlencode($_POST['????']), with your form post value

                    'FFQuestionPK[3]'=>????,
                    'FFAnswer[3]'=>urlencode($_POST['????']),

                'submit'=>true //Do not remove
                    );

            //url-ify the data for the POST
            foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
            rtrim($fields_string,'&amp;');

            //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_RETURNTRANSFER,true);

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

            //Debug
            //var_dump($result);
            //var_dump(curl_getinfo($ch));

            //Generate eMail (If Required)
            $name1 = $_POST['Forename'];
            $name2 = $_POST['Surname'];
            $phone = $_POST['Office'];
            $email = $_POST['Email'];
            $comments = $_POST['companyName'];

            $message = "*** This is a message sent from the website contact form ***\r\n\r\n";
            $message .= "Contact Name: $name1 $name2\r\n";
            $message .= "Contact Number: $phone\r\n";
            $message .= "Email: $email\r\n";
            $message .= "Business: $comments\r\n\r\n------------ END -------------";

            if(mail('info@DOMAIN.co.uk', 'Website Contact Form', $message, "From: YOU@DOMAIN.co.uk\r\n")) {
                $emailStatus = 'Form Sent.';
            }else{
                $emailStatus = 'Form Not Sent. Please contact NAME on TELEPHONE.';
            }

            //close connection
            curl_close($ch);
        }
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<meta charset="utf-8">
<meta name="robots" content="noarchive">
<TITLE>Contact Form</TITLE>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
</HEAD>

<BODY>
<div>

<?php echo "Email Status: $emailStatus"; ?>

    <form method="post" action="">
        <table width="450px" border="0">
            <th colspan="2">Company Details</th>
            <tr>  
                <td valign="top"> <label for="companyName">Company Name</label> </td>
                <td valign="top"> <input type="text" name="companyName" value="<?php echo $_POST['companyName']; ?>" /> </td>
            </tr>
            <tr>  
                <td valign="top"> <label for="companyAddressLine1">Company Address</label> </td>
                <td valign="top"> <input type="text" name="companyAddressLine1" value="<?php echo $_POST['companyAddressLine1']; ?>"/> </td>
            </tr>
            <tr>  
                <td valign="top"> <label for="companyAddressLine2"></label> </td>
                <td valign="top"> <input type="text" name="companyAddressLine2" value="<?php echo $_POST['companyAddressLine2']; ?>"/> </td>
            </tr>
            <tr>  
                <td valign="top"> <label for="companyAddressLine3">Town</label> </td>
                <td valign="top"> <input type="text" name="companyAddressLine3" value="<?php echo $_POST['companyAddressLine3']; ?>"/> </td>
            </tr>
            <tr>  
                <td valign="top"> <label for="companyPostcode">Postcode</label> </td>
                <td valign="top"> <input type="text" name="companyPostcode" value="<?php echo $_POST['companyPostcode']; ?>"/> </td>
            </tr>
            <th colspan="2">Your Details</th>
            <tr>  
                <td valign="top"> <label for="Title">Title</label> </td>
                <td valign="top"> <select name="Title">
                                      <option value="1">Mr</option>
                                      <option value="2">Mrs</option>
                                      <option value="3">Miss</option>
                                      <option value="4">Ms</option>
                                  </select> </td>
            </tr>
            <tr>  
                <td valign="top"> <label for="Forename">First Name</label> </td>  
                <td valign="top"> <input type="text" name="Forename" value="<?php echo $_POST['Forename']; ?>"/> </td>
            </tr>
            <tr>  
                <td valign="top"> <label for="surname">Surname</label> </td>
                <td valign="top"> <input type="text" name="Surname" value="<?php echo $_POST['Surname']; ?>"/> </td>
            </tr>
            <tr>  
                <td valign="top"> <label for="Email">Email</label> </td>
                <td valign="top"> <input type="text" name="Email" value="<?php echo $_POST['Email']; ?>"/> </td>
            </tr>
            <tr>  
                <td valign="top"> <label for="Office">Office Telephone</label> </td>
                <td valign="top"> <input type="text" name="Office" value="<?php echo $_POST['Office']; ?>"/> </td>
            </tr>
            <tr>  
                <td valign="top"> <label for="Mobile">Mobile</label> </td>
                <td valign="top"> <input type="text" name="Mobile" value="<?php echo $_POST['Mobile']; ?>"/> </td>
            </tr>
            <tr>  
                <td valign="top"> <input name="submitButton" type="submit" value="Submit"> <a href=""></a> </td>
            </tr>
        </table>
    </form>
</DIV>

</BODY>
</HTML>
EN

回答 1

Stack Overflow用户

发布于 2019-02-24 01:01:44

您可以像页面中所说那样使用$_POST['item_meta'][30]https://formidableforms.com/knowledgebase/frm_after_create_entry/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38072324

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档