Home › Forums › Quform WordPress › Form method post to external URL
- This topic has 11 replies, 4 voices, and was last updated 10 years, 4 months ago by Ally.
- AuthorPosts
- May 2, 2013 at 9:25 am #4225atdevParticipant
How/where do I make changes to the form so that it post posts to an external site?
For example my html version of the form I currently using is coded like this:
<form action="http://www.ExampleSite.com/" method="post"> ...
Thanks in advance for you help
May 2, 2013 at 10:10 am #4229AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
May 3, 2013 at 3:16 am #4246atdevParticipantI have followed the instructions and setup correctly but it times out with a pop up error “an error occured submitting the form”
How can I send you details in private so you can see the error, etc?
Thanks
May 5, 2013 at 4:05 pm #4268AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
May 15, 2013 at 8:45 pm #4444schinelParticipantHi, I’m encountering the same error when following the above guide. I will send an email as well with my code. Thank you
May 15, 2013 at 9:23 pm #4446schinelParticipantI think it will be easier to just post here. I have tested this code using a basic webpage with a regular php form and know that it works. Please advise.
—————————————————————–
functions.php entry
—————————————————————–
function setup_post_data($form) {$cert_file = 'defined here';
$cert_pwd = 'defined here';
$curl = curl_init();curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)',
CURLOPT_URL => 'https://remote.ip.address.here/setup.php',
CURLOPT_SSLCERT => $cert_file,
CURLOPT_SSLCERTPASSWD => $cert_pwd,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
'account' => $_POST['iphorm_1_1'],
'email' => $_POST['iphorm_1_2']
)
));// When I add this part the error occurs
$xml = new SimpleXMLElement(curl_exec($curl));if(!$xml) {
echo "Curl Error : " . curl_error($curl);
} else {
curl_close($curl);
$data = array();
foreach ($xml->children() as $child) {
$data[$child->getName()] = strval($child);
}
if ($data['status'] == "ACK_SETUP") {
$msgsub = str_replace('email account', 'email account (<b>'.$data['new_email'].'</b>)', $data['message']);
return $msgsub;
} elseif (preg_match('/NACK/',$data['status'])) {
if ($data['status'] == 'NACK_ACCT_LOCKED') {
return $data['message'];
} elseif ($data['status'] != 'NACK_ACCT_LOCKED') {
return $data['message'];
}
}
}
}
add_action('iphorm_post_process_1', 'setup_post_data', 10, 1);
May 16, 2013 at 8:21 am #4451AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
May 27, 2013 at 9:48 pm #4573schinelParticipantThank you, I was able to resolve the error and connect to the remote file.
Now, I would like to return a response from the remote file and display it in the Success Message field area or somewhere on the page, I tried using return and echo, but nothing displays.
So, my question is from the functions.php file, how can I display messages from the remote file onto the form page, possibly in the Success Message field area?
May 28, 2013 at 10:56 am #4577AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
May 28, 2013 at 9:40 pm #4591schinelParticipantThanks, that worked perfectly!
August 24, 2014 at 5:30 pm #12271thgoreParticipantIs there a way to actually post the submission TO an external URL? E.g. I’m trying to post to a 3rd party hotel booking engine. The submission needs to redirect to the external url with form parameters.
I have added the code from your guide already.
August 26, 2014 at 3:59 pm #12286AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- This reply was modified 9 years, 1 month ago by Ally.
- AuthorPosts
- You must be logged in to reply to this topic.