Sending Selected Field Data using PHP and API's.
I am using an API to submit form data to a third party CRM database.
Here is the html of the form...
<div class="column last">
<label for="role">What is your role?</label>
<select name="role" id="role">
<option value="noresponse">Please select one</option>
<option value="reseller">Reseller</option>
<option value="researcher">Researcher</option>
<option value="end-user">End-user</option>
<option value="other">Other</option>
</select>
</div>
And here is the php that sends the selected field data using an API.
$hubspotutk, 'ipAddress' => $ip_addr, 'pageUrl' =>
'http://www.suntechmed.com/index.php?option=com_chronoforms&chronoform=test_form',
'pageName' => 'Test Form' );
$hs_context_json = json_encode($hs_context);
//Need to populate these varilables with values from the form.
$str_post = "firstname=" . urlencode($_POST["firstname"])
. "&lastname=" . urlencode($_POST["lastname"])
. "&company=" . urlencode($_POST["company"])
. "&role=" . urlencode($POST["role"])
. "&address=" . urlencode($_POST["address"])
. "&city=" . urlencode($_POST["city"])
. "&state=" . urlencode($_POST["state"])
. "&zip=" . urlencode($_POST["zip"])
. "&email=" . urlencode($_POST["email"])
. "&hs_context=" . urlencode($hs_context_json);
//Leave this one be :)'
//replace the values in this URL with your portal ID and your form GUID
$endpoint =
'https://forms.hubspot.com/uploads/form/v2/myHubspotID/b9752739-c9a3-4dc3-bf34-cb23679a41d4';
$ch = @curl_init();
@curl_setopt($ch, CURLOPT_POST, true);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $str_post);
@curl_setopt($ch, CURLOPT_URL, $endpoint);
@curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:
application/x-www-form-urlencoded'));
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = @curl_exec($ch); //Log the response from HubSpot as needed.
@curl_close($ch);
echo $response;
?>
The fields that are simple text fields make the transition just fine.
The problem I am having is that the fields that have select options (like
"role") are not making it to the database.
In fact, it doesn't even show role as an empty field.
If anybody has any suggestions, that would be grand!
No comments:
Post a Comment