Elenchus Elenchus - 5 months ago 76
PHP Question

Sending POST data to a Mautic form

I'm trying to send PayPal POST data to a Mautic form as in this guide.

The only change I made to the code in the example is removing the IP forwarding stuff.

My code seems to be connecting to Mautic and sending the data, as Mautic is creating a new contact in the form submission, but it is only logging the IP address and date of creation - none of the fields are filled in. I tried logging the response from Mautic, and I'm getting a redirect to the form submitted message and an

HTTP code 302
.

Here is the code I'm using to send data to the function:

//collect contact details
$payer_email = $_POST['payer_email'];
$given_name = $_POST['first_name'];
$surname = $_POST['last_name'];
$phone = $_POST['contact_phone'];

//build array and forward to mautic
$_REQUEST = array('Given name' => $given_name, 'Surname' => $surname, 'Email' => $payer_email, 'Phone' => $phone);
pushMauticForm($_REQUEST, 4);
}


which produces an array like this:

[Email] => buyer@paypalsandbox.com
[Given name] => John
[Surname] => Smith
[Phone] =>


The field names match my form field labels, and are in the same order.

I feel like I'm missing something simple, but I just can't figure out what it is. Any ideas?

Answer

My guess is that you try to send the field labels, but Mautic needs the field aliases. Try something like this:

pushMauticForm(
    array(
        'payer_email' => $_POST['payer_email'],
        'given_name' => $_POST['first_name'],
        'surname' => $_POST['last_name'],
        'phone' => $_POST['contact_phone'],
    ),
    4
);

Double check the real aliases. The best way to do that is probably when you click in the Form detail page the Manual Copy button where you can see the generated HTML of the form. The aliases are there in the <input name="mauticform[>>alias_is_here<<]"/> tags.

Comments