function dpp_set_post_content($entry, $form)
{
    //Gravity Forms has validated the data
    //Our Custom Form Submitted via PHP will go here
    // Lets get the IDs of the relevant fields and prepare an email message
    $message = print_r($entry, true);
    // In case any of our lines are larger than 70 characters, we should use wordwrap()
    $message = wordwrap($message, 70);
    // Send for debugging
    // mail('*****@*****.**', 'Getting the Gravity Form Field IDs', $message);
    // Post the form to a specific URL
    function post_to_url($url, $data)
    {
        $fields = '';
        foreach ($data as $key => $value) {
            $fields .= $key . '=' . $value . '&';
        }
        rtrim($fields, '&');
        $post = curl_init();
        curl_setopt($post, CURLOPT_URL, $url);
        curl_setopt($post, CURLOPT_POST, count($data));
        curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($post);
        curl_close($post);
    }
    // Handle the form differently based on form ID
    if ($form["id"] == 1) {
        // Application Page
        $data = array("first_name" => $entry["7"], "last_name" => $entry["8"], "phone" => $entry["4"], "email" => $entry["3"], "loan_type" => $entry["5"], "loan_amount" => $entry["10"], "gross_income" => $entry["12"], "monthly_payment" => $entry["11"], "state" => $entry["9"], "time_to_call" => $entry["6"], "formName" => "Application");
        post_to_url("https://login.debtpaypro.com/post/d5b826014a9552022f1292804afc72d2bc27b721/", $data);
    }
}
function set_post_content($entry, $form)
{
    //Gravity Forms has validated the data
    //Our Custom Form Submitted via PHP will go here
    // Lets get the IDs of the relevant fields and prepare an email message
    $message = print_r($entry, true);
    // In case any of our lines are larger than 70 characters, we should use wordwrap()
    $message = wordwrap($message, 70);
    // Send for debugging
    // mail('*****@*****.**', 'Getting the Gravity Form Field IDs', $message);
    // Post the form to a specific URL
    function post_to_url($url, $data)
    {
        $fields = '';
        foreach ($data as $key => $value) {
            $fields .= $key . '=' . $value . '&';
        }
        rtrim($fields, '&');
        $post = curl_init();
        curl_setopt($post, CURLOPT_URL, $url);
        curl_setopt($post, CURLOPT_POST, count($data));
        curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($post);
        curl_close($post);
    }
    // Handle the form differently based on form ID
    if ($form["id"] == 2) {
        // Contact Page Form
        $data = array("first_name" => $entry["1.3"], "last_name" => $entry["1.6"], "phone" => $entry["2"], "email" => $entry["3"], "comment" => $entry["4"], "terms" => $entry["5.1"], "formName" => "Contact Us");
        post_to_url("https://login.debtpaypro.com/post/c85973ce21e7cd40a3affbfb435623a0a9349283/", $data);
    } elseif ($form["id"] == 3) {
        // Get A Quote
        $data = array("loan_amount" => $entry["1"], "loan_status" => $entry["2"], "annual_income" => $entry["3"], "loan_type" => $entry["4"], "first_name" => $entry["6.3"], "last_name" => $entry["6.6"], "phone" => $entry["7"], "email" => $entry["8"], "terms" => $entry["9.1"], "formName" => "Sidebar Application");
        post_to_url("https://login.debtpaypro.com/post/c85973ce21e7cd40a3affbfb435623a0a9349283/", $data);
    } elseif ($form["id"] == 4) {
        // Sidebar Application
        $data = array("loan_amount" => $entry["1"], "loan_status" => $entry["2"], "annual_income" => $entry["3"], "loan_type" => $entry["4"], "first_name" => $entry["6.3"], "last_name" => $entry["6.6"], "phone" => $entry["7"], "email" => $entry["8"], "formName" => "Sidebar Application");
        post_to_url("https://login.debtpaypro.com/post/c85973ce21e7cd40a3affbfb435623a0a9349283/", $data);
    } elseif ($form["id"] == 1 || $form["id"] == 5) {
        // We dont know where this is coming from, send for debugging
        mail('*****@*****.**', 'Getting the Gravity Form Field IDs', $message);
    }
}
Example #3
0
<?php

require_once 'Routes.php';
$result = new Routes();
if ($_POST) {
    echo post_to_url("http://www.mirestful.es/api/users", $_POST);
} else {
    ?>
ADD RECORD.
<form action="" method="post">
<input type="text" name="name" placeholder="Name" /><br>
<input type="text" name="email" placeholder="Email" /><br>
<input type="hidden" name="_METHOD" value="POST" />
<input type="submit" value="A D D" />
</form>
<?php 
}
function post_to_url($_url, $_data)
{
    $mfields = '';
    foreach ($_data as $key => $val) {
        $mfields .= $key . '=' . $val . '&';
    }
    $mfields = rtrim($mfields, '&');
    $pst = curl_init();
    curl_setopt($pst, CURLOPT_URL, $_url);
    curl_setopt($pst, CURLOPT_POST, count($_data));
    curl_setopt($pst, CURLOPT_POSTFIELDS, $mfields);
    curl_setopt($pst, CURLOPT_RETURNTRANSFER, 1);
    $res = curl_exec($pst);
    curl_close($pst);
function set_post_content($entry, $form)
{
    // Lets get the IDs of the relevant fields and prepare an email message
    //$message = print_r($entry, true);
    // In case any of our lines are larger than 70 characters, we should use wordwrap()
    //$message = wordwrap($message, 70);
    // Send
    function post_to_url($url, $data)
    {
        $fields = '';
        foreach ($data as $key => $value) {
            $fields .= $key . '=' . $value . '&';
        }
        rtrim($fields, '&');
        $post = curl_init();
        curl_setopt($post, CURLOPT_URL, $url);
        curl_setopt($post, CURLOPT_POST, count($data));
        curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($post);
        curl_close($post);
    }
    $data = array("first_name" => $entry["1"], "last_name" => $entry["2"], "phone" => $entry["4"], "email" => $entry["5"], "debt_amount" => $entry["3"], "loan_type" => $entry["6"]);
    post_to_url("https://client.debtpaypro.com/post/b19bb0529021580bb89838de10421db95494d397/", $data);
}