Skip to content

Unable to retrieve custom field data from the HTML form

Hi

I have recently added some custom fields to a form (Last Name, Country) but the data isn't syncing properly when the users fill in the form - I can get the First Name and E-mail just fine, but not the custom ones.

This is what I have in the list:

Surname [Surname,fallback=]
Country [Country,fallback=]

I have adapted the "Subscribe via AJAX" template available in the API documentation, so I will just insert my changes here.

This is what I have in my PHP file:

//POST variables
$name = $_POST['name'];
$surname = $_POST['surname'];
$email = $_POST['email'];
$country = $_POST['country'];

//subscribe
$postdata = http_build_query(
array(
'name' => $name,
'surname' => $surname,
'email' => $email,
'country' => $country,
'list' => $sendy_list,
'boolean' => 'true'
)
);

I believe this is a problem of something being in a different case when it shouldn't, but I can't figure out what I need to change.

Any help would be greatly appreciated!

Thank you so much.

Cheers
Bruno

Comments

  • BenBen
    edited October 2016

    Hi,

    //subscribe $postdata = http_build_query( array( 'name' => $name, 'surname' => $surname, 'email' => $email, 'country' => $country, 'list' => $sendy_list, 'boolean' => 'true' ) );

    The 'surname' and 'country' in the above line should be 'Surname' and 'Country' respectively as your custom field was created as:

    Surname
    Country

    Your PHP code should match the 'case' of your custom fields.

    Thanks.

    Best regards,
    Ben

  • Hi Ben

    Thank you so much, that worked! :D

    Kind regards
    Bruno

This discussion has been closed.