How can I pass form data value to PHP file


#1

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!


#2

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:


#3

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


#4

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.


#5

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.