php - Formidable Pro form - $ Post hook not working -
hi looking formidable pro web form send data crm system, after submit button cliked
i have 90% coded reason not sending information through
i have added website using code snippets plugin wordpress, , set snippet such tht when form x submitted should post various bits of data through crm system
the data formidable pro form output in following format [21], or [18] etc have removed set of brackets around data - there set of brackets[] in formatting
attached developers guide , example code crm system , own 90% developed code ideas why not connecting ?
my code
add_action('frm_after_create_entry', 'yourfunctionname', 30, 2); function yourfunctionname($entry_id, $form_id){ if($form_id == 2){ //replace 5 id of form //set post variables $url = 'https://secure4.mortgagekeeperonline.co.uk/mywebsitelink/php/newmortgagequickdetails.php'; // 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 factfind 'ffquestionpk[1]'=>11884, 'ffanswer[1]'=>urlencode($_post['23']), // looking 'ffquestionpk[2]'=>11885, 'ffanswer[2]'=>urlencode($_post['24']), // credit history // increment ffquestionpk , ffanswer numbers in square brackets 1 // replace ???? in 'ffquestionpk[3]'=>????, factfind question pk number // , replace ??? in 'ffanswer[3]'=>urlencode($_post['????']), 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 data post foreach($fields $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); //open connection $ch = curl_init(); //set 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 = "*** message sent 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== developers example code <?php //set post variables $url = 'https://secure.mortgagekeeperonline.co.uk/sitename/php/newmortgagequickdetails.php'; // 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 factfind 'ffquestionpk[1]'=>11604, 'ffanswer[1]'=>urlencode($_post['datemoved1']), 'ffquestionpk[2]'=>11636, 'ffanswer[2]'=>urlencode($_post['basic1']), // increment ffquestionpk , ffanswer numbers in square brackets 1 // replace ???? in 'ffquestionpk[3]'=>????, factfind question pk number // , replace ??? in 'ffanswer[3]'=>urlencode($_post['????']), form post value 'ffquestionpk[3]'=>????, 'ffanswer[3]'=>urlencode($_post['????']), 'submit'=>true //do not remove ); //url-ify data post foreach($fields $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); //open connection $ch = curl_init(); //set 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 = "*** message sent 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>
Comments
Post a Comment