APIs & Integrations

jbensous
Member

How can I pass form data value to PHP file

I need to pass firstname, lastname and email to a php file. I used the internal form field name but this did not work. This is the code;

// Passed Values
$firstname = “firstname”; // first name entered in form
$lastname = “lastname”; // last name entered in form
$email = “email”; // email

Is there a specific way this needs to be done to work because this doesn’t pull in anything. Thanks!

0 Upvotes
4 Replies 4
rmcdiarmid
Member

How can I pass form data value to PHP file

encapsulate it in javascript. I assume you are getting “firstname” and “lastname” from a javascript object?

or you could write the field names to a cookie - and then access that from PHP.

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

How can I pass form data value to PHP file

Hi @jbensous,

To be honest, I’m not particularly fluent in PHP. I’d recommend checking out stack overflow for some tips/recommendations from folks with more PHP experience. If you have any HubSpot-specific questions, I’d be more than happy to continue working with you.

0 Upvotes
jbensous
Member

How can I pass form data value to PHP file

Yes. I tried that code but that did not work. NULL. No values were passed. Is there something I am missing here?

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

How can I pass form data value to PHP file

Hi @jbensous,

You’ll likely want to use PHP’s $_POST superglobal to retrieve the value of the input tag via the name of the HTML tag:

0 Upvotes