APIs & Integrations

mcmstart
Member

Using an outside form using ajax and php - is this possible?

What’s the best way to use my own form on Hubspot that doesn’t send the data to the Hubspot CRM?

I understand that you can create a form in the Hubspot backend - but I want to send the data elsewhere.

I’d like to send the info to another database. If this isn’t possible, we will send the data in an email.

I created a form that works in a test site, but when I try it on a Hubspot landing page the console tells me:

No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://inviacom-2399961.hs-sites.com’ is therefore not allowed access.

Can anyone tell me what my next steps will be?

Thanks!

Alternately, is there a way that I can use Hubspot’s built-in forms to ONLY send an email and not put the data into the CRM?

0 Upvotes
3 Replies 3
nickdeckerdevs
Contributor | Diamond Partner
Contributor | Diamond Partner

Using an outside form using ajax and php - is this possible?

Here is an example of this in .htaccess file if running an apache server where you are submitting your form to:

<IfModule mod_headers.c>
    Header add Access-Control-Allow-Origin "http://dev.domain.com"
    Header add Access-Control-Allow-Methods: "POST"
</IfModule>

Then in your form you create on hubspot:

<form method="post" action="http://dev.domain.com/form-results">
0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Using an outside form using ajax and php - is this possible?

@mcmstart The error is because we don’t allow cross-origin requests and the request would have to be made server-side which you wouldn’t be able to do on one of our Landing Pages. You will need to create a custom form to handle sending the data elsewhere. do you have the marketing tools? You could send out an email from HubSpot automatically using a workflow when the form is submitted.

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Using an outside form using ajax and php - is this possible?

@mcmstart Rereading this it might be your end that isn’t accepting a Cross Origin request and you will need to allow cross-origin requests to receive it.

0 Upvotes