Form method post to external URL

Home Forums Quform WordPress Form method post to external URL

This topic is: resolved
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #4225
    atdev
    Participant

    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

    #4229
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #4246
    atdev
    Participant

    I 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

    #4268
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #4444
    schinel
    Participant

    Hi, I’m encountering the same error when following the above guide. I will send an email as well with my code. Thank you

    #4446
    schinel
    Participant

    I 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);

    #4451
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #4573
    schinel
    Participant

    Thank 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?

    #4577
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #4591
    schinel
    Participant

    Thanks, that worked perfectly!

    #12271
    thgore
    Participant

    Is 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.

    #12286
    Ally
    Support Staff

    You 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 8 years, 4 months ago by Ally.
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy