Здравствуйте, я ищу, чтобы получить огромную профессиональную веб-форму для отправки данных в мою систему CRM, после нажатия кнопки отправки
Я на 90% закодировал его, но по какой-то причине он просто не отправляет информацию через
Я добавил его на свой веб-сайт, используя плагин code snippets для wordpress, и установил этот фрагмент таким образом, что при отправке формы x он должен публиковать различные фрагменты данных в системе crm
Данные из огромной формы выводятся в следующем формате [21] или [18] и т. Д. Я удалил этот набор скобок вокруг данных — так как в форматировании уже есть набор скобок []
прилагаемое руководство для разработчиков и пример кода из системы crm и мой собственный 90% разработанный код. Есть идеи, почему он не подключается?
Мой код
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('[email protected]', 'Website Contact Form', $message, "From: [email protected]\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,'&');
//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('[email protected]', 'Website Contact Form', $message, "From: [email protected]\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>
Задача ещё не решена.
Других решений пока нет …