Submit data to Mautic [via form]

Hi i know our good friend John Linhart published a post on Medium about it

But like me there are so many user that are not programmer… :(



So if we can be more clear in the steps to make our beautiful app Mautic work in our company and have a space in our hearts please lets try to figure out a way to do it.



Here is the script code publish by John.

Code:
<?php /** * Push data to a Mautic form * * @param array $data The data submitted by your form * @param integer $formId Mautic Form ID * @param string $ip IP address of the lead * @return string */ function pushMauticForm($data, $formId, $ip) { $data['formId'] = $formId; // return has to be part of the form data array if (!isset($data['return'])) { $data['return'] = 'http://where-to-redirect.com'; }
$data = array('mauticform' => $data);
// Change [path-to-mautic] to URL where your Mautic is
$formUrl =  'http://[path-to-mautic]/form/submit?formId=' . $formId;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $formUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array("HTTP_X_FORWARDED_FOR: $ip"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
return $response;     

}


Now we wanna know what field we have to change to make this beutifull script code work for us.

Hi i know our good friend John Linhart published a post on Medium about it
But like me there are so many user that are not programmer… :frowning:

So if we can be more clear in the steps to make our beautiful app Mautic work in our company and have a space in our hearts please lets try to figure out a way to do it.

Here is the script code publish by John.

[code]<?php
/**

  • Push data to a Mautic form

  • @param array $data The data submitted by your form

  • @param integer $formId Mautic Form ID

  • @param string $ip IP address of the lead

  • @return string
    */
    function pushMauticForm($data, $formId, $ip)
    {
    $data[‘formId’] = $formId;
    // return has to be part of the form data array
    if (!isset($data[‘return’])) {
    $data[‘return’] = ‘http://where-to-redirect.com’;
    }

    $data = array(‘mauticform’ => $data);
    // Change [path-to-mautic] to URL where your Mautic is
    $formUrl = ‘http://[path-to-mautic]/form/submit?formId=’ . $formId;

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $formUrl);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(“HTTP_X_FORWARDED_FOR: $ip”));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($ch);

    curl_close($ch);
    return $response;
    }[/code]

Now we wanna know what field we have to change to make this beutifull script code work for us.

I don’t want to be rude or something, but if you want to connect 2 different systems together, you need a person with the skills to do that. That person has to know both systems and some programming. You didn’t even mention what the second system is.

You don’t need to change anything in that script. It’s ready to use. You just have to paste it to the right place and call that function with correct parameters.

As usually in many other areas of life, you have 2 choices:

  1. Learn it and do it yourself.
  2. Pay somebody who has the skills to do it for you.

@escopecz i only wanna is you mark me with a yellow text the variable i have to change :frowning:

You don't need to change anything in that script. It's ready to use. You just have to paste it to the right place and call that function with correct parameters.

It’s a function. All you have to do is to call it with the parameters. Example of how to call it is in the Medium article.

@ninjoan , did you succeed configuring PHP script? Did it run alright? Where did you paste? Did you create any file .php?