<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How I can get new Contacts from 3 different forms in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/How-I-can-get-new-Contacts-from-3-different-forms/m-p/797010#M64211</link>
    <description>&lt;P&gt;&lt;BR /&gt;I'm writing to ask you to check if the HubSpot integration with our website is working properly. Our goal is to automatically create contacts in HubSpot when people fill out forms on our website.&lt;/P&gt;&lt;P&gt;We use AJAX requests to send the form data to the server. Once the form is successfully submitted, we execute another AJAX request to create the contact in HubSpot. We hope that this process is properly configured and meets the requirements of HubSpot integration.&lt;/P&gt;&lt;P&gt;&amp;lt;pre&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;code&amp;gt;&lt;BR /&gt;&amp;amp;lt;!-- ?php&lt;BR /&gt;function submitContactForm(form) {&lt;BR /&gt;var formData = new FormData(form);&lt;BR /&gt;var data = {&lt;BR /&gt;type: "send_mail",&lt;BR /&gt;form: "big",&lt;BR /&gt;expinp: formData.get("expinp"),&lt;BR /&gt;origin: formData.get("origin"),&lt;BR /&gt;destination: formData.get("destination"),&lt;BR /&gt;containers: formData.get("containers"),&lt;BR /&gt;containert: formData.get("containert"),&lt;BR /&gt;weight: formData.get("weight"),&lt;BR /&gt;ncontainer: formData.get("ncontainer"),&lt;BR /&gt;hazmat: formData.get("hazmat"),&lt;BR /&gt;etaerd: formData.get("etaerd"),&lt;BR /&gt;datestart: formData.get("datestart"),&lt;BR /&gt;fname: formData.get("fname"),&lt;BR /&gt;email: formData.get("email"),&lt;BR /&gt;letter: formData.get("letter")&lt;BR /&gt;};&lt;BR /&gt;var queryString = Object.keys(data).map(function(key) {&lt;BR /&gt;return key + '=' + encodeURIComponent(data[key]);&lt;BR /&gt;}).join('&amp;amp;amp;');&lt;BR /&gt;var url = window.location.href + '?data=' + encodeURIComponent(queryString);&lt;/P&gt;&lt;P&gt;// Make an AJAX request to handle form submission&lt;BR /&gt;var xhr = new XMLHttpRequest();&lt;BR /&gt;xhr.open("GET", url, true);&lt;BR /&gt;xhr.onreadystatechange = function() {&lt;BR /&gt;if (xhr.readyState === 4 &amp;amp;&amp;amp; xhr.status === 200) {&lt;BR /&gt;if (xhr.responseText === "t") {&lt;BR /&gt;// Success&lt;BR /&gt;alert("Form submitted successfully!");&lt;BR /&gt;form.reset();&lt;BR /&gt;} else {&lt;BR /&gt;// Error&lt;BR /&gt;alert("Form submission failed!");&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;xhr.send();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;function submitPopupForm(form) {&lt;BR /&gt;var formData = new FormData(form);&lt;BR /&gt;var data = {&lt;BR /&gt;type: "send_mail",&lt;BR /&gt;form: "popup",&lt;BR /&gt;compn: formData.get("compn"),&lt;BR /&gt;contactn: formData.get("contactn"),&lt;BR /&gt;phone: formData.get("phone"),&lt;BR /&gt;email: formData.get("email"),&lt;BR /&gt;mcn: formData.get("mcn"),&lt;BR /&gt;dot: formData.get("dot"),&lt;BR /&gt;areaofoperation: formData.get("areaofoperation"),&lt;BR /&gt;numoftrucks: formData.get("numoftrucks"),&lt;BR /&gt;numoftrailers: formData.get("numoftrailers"),&lt;BR /&gt;numofdrivers: formData.get("numofdrivers")&lt;BR /&gt;};&lt;BR /&gt;var queryString = Object.keys(data).map(function(key) {&lt;BR /&gt;return key + '=' + encodeURIComponent(data[key]);&lt;BR /&gt;}).join('&amp;amp;amp;');&lt;BR /&gt;var url = window.location.href + '?data=' + encodeURIComponent(queryString);&lt;/P&gt;&lt;P&gt;// Make an AJAX request to handle form submission&lt;BR /&gt;var xhr = new XMLHttpRequest();&lt;BR /&gt;xhr.open("GET", url, true);&lt;BR /&gt;xhr.onreadystatechange = function() {&lt;BR /&gt;if (xhr.readyState === 4 &amp;amp;&amp;amp; xhr.status === 200) {&lt;BR /&gt;if (xhr.responseText === "t") {&lt;BR /&gt;// Success&lt;BR /&gt;alert("Form submitted successfully!");&lt;BR /&gt;form.reset();&lt;BR /&gt;} else {&lt;BR /&gt;// Error&lt;BR /&gt;alert("Form submission failed!");&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;xhr.send();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;function submitMainForm(form) {&lt;BR /&gt;var formData = new FormData(form);&lt;BR /&gt;var data = {&lt;BR /&gt;type: "send_mail",&lt;BR /&gt;form: "small",&lt;BR /&gt;name: formData.get("name"),&lt;BR /&gt;phone: formData.get("phone"),&lt;BR /&gt;email: formData.get("email"),&lt;BR /&gt;subject: formData.get("subject"),&lt;BR /&gt;messaget: formData.get("messaget")&lt;BR /&gt;};&lt;BR /&gt;var queryString = Object.keys(data).map(function(key) {&lt;BR /&gt;return key + '=' + encodeURIComponent(data[key]);&lt;BR /&gt;}).join('&amp;amp;amp;');&lt;BR /&gt;var url = window.location.href + '?data=' + encodeURIComponent(queryString);&lt;/P&gt;&lt;P&gt;// Make an AJAX request to handle form submission&lt;BR /&gt;var xhr = new XMLHttpRequest();&lt;BR /&gt;xhr.open("GET", url, true);&lt;BR /&gt;xhr.onreadystatechange = function() {&lt;BR /&gt;if (xhr.readyState === 4 &amp;amp;&amp;amp; xhr.status === 200) {&lt;BR /&gt;if (xhr.responseText === "t") {&lt;BR /&gt;// Success&lt;BR /&gt;alert("Form submitted successfully!");&lt;BR /&gt;form.reset();&lt;BR /&gt;} else {&lt;BR /&gt;// Error&lt;BR /&gt;alert("Form submission failed!");&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;xhr.send();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;header.php code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;amp;lt;?php&lt;BR /&gt;if (!empty($_GET['data'])) {&lt;BR /&gt;$arr_p = json_decode(str_replace("\\", "", $_GET['data']), true);&lt;BR /&gt;if (!empty($arr_p) &amp;amp;&amp;amp; $arr_p['type'] == "send_mail") {&lt;BR /&gt;$form = $arr_p['form'];&lt;BR /&gt;if ($form == "big") {&lt;BR /&gt;$expinp = $arr_p['expinp'];&lt;BR /&gt;$origin = $arr_p['origin'];&lt;BR /&gt;$destination = $arr_p['destination'];&lt;BR /&gt;$containers = $arr_p['containers'];&lt;BR /&gt;$containert = $arr_p['containert'];&lt;BR /&gt;$weight = $arr_p['weight'];&lt;BR /&gt;$ncontainer = $arr_p['ncontainer'];&lt;BR /&gt;$hazmat = $arr_p['hazmat'];&lt;BR /&gt;$etaerd = $arr_p['etaerd'];&lt;BR /&gt;$datestart = $arr_p['datestart'];&lt;BR /&gt;$fname = $arr_p['fname'];&lt;BR /&gt;$email = $arr_p['email'];&lt;BR /&gt;$letter = $arr_p['letter'];&lt;BR /&gt;if (empty($expinp) || empty($origin) || empty($destination) || empty($containers) || empty($containert) || empty($weight) || empty($ncontainer) || empty($hazmat) || empty($etaerd) || empty($datestart) || empty($fname) || empty($email)) {&lt;BR /&gt;exit("error");&lt;BR /&gt;}&lt;BR /&gt;$res = wp_mail(carbon_get_theme_option('send_email'), 'Get a Quote', "Import or Export : $expinp\nOrigin : $origin\nDestination : $destination\nContainer Size : $containers\nContainer Type : $containert\nWeight in LBS (per container) : $weight\nNumbers of Containers : $ncontainer\nHazmat : $hazmat\nETA or ErD : $etaerd\nDate $datestart\nFirst Name : $fname\nE-mail : $email\nLetter : $letter");&lt;BR /&gt;if ($res) {&lt;BR /&gt;exit("t");&lt;BR /&gt;} else {&lt;BR /&gt;exit("error");&lt;BR /&gt;}&lt;BR /&gt;} else if ($form == "small") {&lt;BR /&gt;$name = $arr_p['name'];&lt;BR /&gt;$phone = $arr_p['phone'];&lt;BR /&gt;$email = $arr_p['email'];&lt;BR /&gt;$subject = $arr_p['subject'];&lt;BR /&gt;$messaget = $arr_p['messaget'];&lt;BR /&gt;if (empty($phone) || empty($name) || empty($email)) {&lt;BR /&gt;exit("error");&lt;BR /&gt;}&lt;BR /&gt;$res = wp_mail(carbon_get_theme_option('send_email'), "Get in touch", "Phone : $phone\nName : $name\nEmail : $email\nMessage : $messaget\nsubject : $subject");&lt;BR /&gt;if ($res) {&lt;BR /&gt;exit("t");&lt;BR /&gt;} else {&lt;BR /&gt;exit("error");&lt;BR /&gt;}&lt;BR /&gt;} else if ($form == "popup") {&lt;BR /&gt;$compn = $arr_p['compn'];&lt;BR /&gt;$contactn = $arr_p['contactn'];&lt;BR /&gt;$phone = $arr_p['phone'];&lt;BR /&gt;$email = $arr_p['email'];&lt;BR /&gt;$mcn = $arr_p['mcn'];&lt;BR /&gt;$dot = $arr_p['dot'];&lt;BR /&gt;$areaofoperation = $arr_p['areaofoperation'];&lt;BR /&gt;$numoftrucks = $arr_p['numoftrucks'];&lt;BR /&gt;$numoftrailers = $arr_p['numoftrailers'];&lt;BR /&gt;$numofdrivers = $arr_p['numofdrivers'];&lt;BR /&gt;if (empty($compn) || empty($contactn) || empty($phone) || empty($email) || empty($mcn) || empty($dot) || empty($areaofoperation) || empty($numoftrucks) || empty($numoftrailers) || empty($numofdrivers)) {&lt;BR /&gt;exit("error");&lt;BR /&gt;}&lt;BR /&gt;$res = wp_mail(carbon_get_theme_option('send_email'), "Become a Carrier", "Company Name : $compn\nContact Name : $contactn\nPhone Number : $phone\nE-mail : $email\nMC № : $mcn\nDOT № : $dot\nArea of Operation : $areaofoperation\n№ of Trucks : $numoftrucks\n№ of Trailers : $numoftrailers\n№ of Drivers : $numofdrivers");&lt;BR /&gt;if ($res) {&lt;BR /&gt;exit("t");&lt;BR /&gt;} else {&lt;BR /&gt;exit("error");&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;// HubSpot Contact Creation&lt;BR /&gt;$hubspot_api_key = 'YOUR_HUBSPOT_API_KEY';&lt;BR /&gt;$hubspot_form_id = 'YOUR_HUBSPOT_FORM_ID';&lt;/P&gt;&lt;P&gt;// Prepare contact data&lt;BR /&gt;$contact_data = array();&lt;BR /&gt;if ($form == "big") {&lt;BR /&gt;// Extract relevant fields from the big form&lt;BR /&gt;$contact_data = array(&lt;BR /&gt;'import_export' =&amp;gt; $expinp,&lt;BR /&gt;'origin' =&amp;gt; $origin,&lt;BR /&gt;'destination' =&amp;gt; $destination,&lt;BR /&gt;'container_size' =&amp;gt; $containers,&lt;BR /&gt;'container_type' =&amp;gt; $containert,&lt;BR /&gt;'weight' =&amp;gt; $weight,&lt;BR /&gt;'num_containers' =&amp;gt; $ncontainer,&lt;BR /&gt;'hazmat' =&amp;gt; $hazmat,&lt;BR /&gt;'eta_erD' =&amp;gt; $etaerd,&lt;BR /&gt;'date' =&amp;gt; $datestart,&lt;BR /&gt;'first_name' =&amp;gt; $fname,&lt;BR /&gt;'email' =&amp;gt; $email,&lt;BR /&gt;'letter' =&amp;gt; $letter&lt;BR /&gt;);&lt;BR /&gt;} else if ($form == "small") {&lt;BR /&gt;// Extract relevant fields from the small form&lt;BR /&gt;$contact_data = array(&lt;BR /&gt;'name' =&amp;gt; $name,&lt;BR /&gt;'phone' =&amp;gt; $phone,&lt;BR /&gt;'email' =&amp;gt; $email,&lt;BR /&gt;'subject' =&amp;gt; $subject,&lt;BR /&gt;'message' =&amp;gt; $messaget&lt;BR /&gt;);&lt;BR /&gt;} else if ($form == "popup") {&lt;BR /&gt;// Extract relevant fields from the popup form&lt;BR /&gt;$contact_data = array(&lt;BR /&gt;'company_name' =&amp;gt; $compn,&lt;BR /&gt;'contact_name' =&amp;gt; $contactn,&lt;BR /&gt;'phone_number' =&amp;gt; $phone,&lt;BR /&gt;'email' =&amp;gt; $email,&lt;BR /&gt;'mcn_number' =&amp;gt; $mcn,&lt;BR /&gt;'dot_number' =&amp;gt; $dot,&lt;BR /&gt;'area_of_operation' =&amp;gt; $areaofoperation,&lt;BR /&gt;'num_trucks' =&amp;gt; $numoftrucks,&lt;BR /&gt;'num_trailers' =&amp;gt; $numoftrailers,&lt;BR /&gt;'num_drivers' =&amp;gt; $numofdrivers&lt;BR /&gt;);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Make API request to create the contact&lt;BR /&gt;$hubspot_url = "&lt;A href="https://api.hubapi.com/contacts/v1/contact/?hapikey=" target="_blank" rel="noopener"&gt;https://api.hubapi.com/contacts/v1/contact/?hapikey=&lt;/A&gt;" . $hubspot_api_key . "&amp;amp;formGuid=" . $hubspot_form_id;&lt;BR /&gt;$hubspot_headers = array(&lt;BR /&gt;'Content-Type: application/json',&lt;BR /&gt;);&lt;BR /&gt;$hubspot_data = json_encode($contact_data);&lt;/P&gt;&lt;P&gt;$hubspot_curl = curl_init();&lt;BR /&gt;curl_setopt($hubspot_curl, CURLOPT_URL, $hubspot_url);&lt;BR /&gt;curl_setopt($hubspot_curl, CURLOPT_HTTPHEADER, $hubspot_headers);&lt;BR /&gt;curl_setopt($hubspot_curl, CURLOPT_POST, true);&lt;BR /&gt;curl_setopt($hubspot_curl, CURLOPT_POSTFIELDS, $hubspot_data);&lt;BR /&gt;curl_setopt($hubspot_curl, CURLOPT_RETURNTRANSFER, true);&lt;BR /&gt;$hubspot_response = curl_exec($hubspot_curl);&lt;BR /&gt;curl_close($hubspot_curl);&lt;/P&gt;&lt;P&gt;// Handle HubSpot response&lt;BR /&gt;$hubspot_response_data = json_decode($hubspot_response, true);&lt;BR /&gt;if ($hubspot_response_data &amp;amp;&amp;amp; !empty($hubspot_response_data['status']) &amp;amp;&amp;amp; $hubspot_response_data['status'] == "error") {&lt;BR /&gt;// Failed to create the contact in HubSpot&lt;BR /&gt;exit("HubSpot integration error: " . $hubspot_response_data['message']);&lt;BR /&gt;} else {&lt;BR /&gt;// Contact created successfully in HubSpot&lt;BR /&gt;exit("t");&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;?&amp;gt;&lt;/P&gt;</description>
    <pubDate>Mon, 22 May 2023 12:38:31 GMT</pubDate>
    <dc:creator>Paulua</dc:creator>
    <dc:date>2023-05-22T12:38:31Z</dc:date>
    <item>
      <title>How I can get new Contacts from 3 different forms</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-I-can-get-new-Contacts-from-3-different-forms/m-p/797010#M64211</link>
      <description>&lt;P&gt;&lt;BR /&gt;I'm writing to ask you to check if the HubSpot integration with our website is working properly. Our goal is to automatically create contacts in HubSpot when people fill out forms on our website.&lt;/P&gt;&lt;P&gt;We use AJAX requests to send the form data to the server. Once the form is successfully submitted, we execute another AJAX request to create the contact in HubSpot. We hope that this process is properly configured and meets the requirements of HubSpot integration.&lt;/P&gt;&lt;P&gt;&amp;lt;pre&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;code&amp;gt;&lt;BR /&gt;&amp;amp;lt;!-- ?php&lt;BR /&gt;function submitContactForm(form) {&lt;BR /&gt;var formData = new FormData(form);&lt;BR /&gt;var data = {&lt;BR /&gt;type: "send_mail",&lt;BR /&gt;form: "big",&lt;BR /&gt;expinp: formData.get("expinp"),&lt;BR /&gt;origin: formData.get("origin"),&lt;BR /&gt;destination: formData.get("destination"),&lt;BR /&gt;containers: formData.get("containers"),&lt;BR /&gt;containert: formData.get("containert"),&lt;BR /&gt;weight: formData.get("weight"),&lt;BR /&gt;ncontainer: formData.get("ncontainer"),&lt;BR /&gt;hazmat: formData.get("hazmat"),&lt;BR /&gt;etaerd: formData.get("etaerd"),&lt;BR /&gt;datestart: formData.get("datestart"),&lt;BR /&gt;fname: formData.get("fname"),&lt;BR /&gt;email: formData.get("email"),&lt;BR /&gt;letter: formData.get("letter")&lt;BR /&gt;};&lt;BR /&gt;var queryString = Object.keys(data).map(function(key) {&lt;BR /&gt;return key + '=' + encodeURIComponent(data[key]);&lt;BR /&gt;}).join('&amp;amp;amp;');&lt;BR /&gt;var url = window.location.href + '?data=' + encodeURIComponent(queryString);&lt;/P&gt;&lt;P&gt;// Make an AJAX request to handle form submission&lt;BR /&gt;var xhr = new XMLHttpRequest();&lt;BR /&gt;xhr.open("GET", url, true);&lt;BR /&gt;xhr.onreadystatechange = function() {&lt;BR /&gt;if (xhr.readyState === 4 &amp;amp;&amp;amp; xhr.status === 200) {&lt;BR /&gt;if (xhr.responseText === "t") {&lt;BR /&gt;// Success&lt;BR /&gt;alert("Form submitted successfully!");&lt;BR /&gt;form.reset();&lt;BR /&gt;} else {&lt;BR /&gt;// Error&lt;BR /&gt;alert("Form submission failed!");&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;xhr.send();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;function submitPopupForm(form) {&lt;BR /&gt;var formData = new FormData(form);&lt;BR /&gt;var data = {&lt;BR /&gt;type: "send_mail",&lt;BR /&gt;form: "popup",&lt;BR /&gt;compn: formData.get("compn"),&lt;BR /&gt;contactn: formData.get("contactn"),&lt;BR /&gt;phone: formData.get("phone"),&lt;BR /&gt;email: formData.get("email"),&lt;BR /&gt;mcn: formData.get("mcn"),&lt;BR /&gt;dot: formData.get("dot"),&lt;BR /&gt;areaofoperation: formData.get("areaofoperation"),&lt;BR /&gt;numoftrucks: formData.get("numoftrucks"),&lt;BR /&gt;numoftrailers: formData.get("numoftrailers"),&lt;BR /&gt;numofdrivers: formData.get("numofdrivers")&lt;BR /&gt;};&lt;BR /&gt;var queryString = Object.keys(data).map(function(key) {&lt;BR /&gt;return key + '=' + encodeURIComponent(data[key]);&lt;BR /&gt;}).join('&amp;amp;amp;');&lt;BR /&gt;var url = window.location.href + '?data=' + encodeURIComponent(queryString);&lt;/P&gt;&lt;P&gt;// Make an AJAX request to handle form submission&lt;BR /&gt;var xhr = new XMLHttpRequest();&lt;BR /&gt;xhr.open("GET", url, true);&lt;BR /&gt;xhr.onreadystatechange = function() {&lt;BR /&gt;if (xhr.readyState === 4 &amp;amp;&amp;amp; xhr.status === 200) {&lt;BR /&gt;if (xhr.responseText === "t") {&lt;BR /&gt;// Success&lt;BR /&gt;alert("Form submitted successfully!");&lt;BR /&gt;form.reset();&lt;BR /&gt;} else {&lt;BR /&gt;// Error&lt;BR /&gt;alert("Form submission failed!");&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;xhr.send();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;function submitMainForm(form) {&lt;BR /&gt;var formData = new FormData(form);&lt;BR /&gt;var data = {&lt;BR /&gt;type: "send_mail",&lt;BR /&gt;form: "small",&lt;BR /&gt;name: formData.get("name"),&lt;BR /&gt;phone: formData.get("phone"),&lt;BR /&gt;email: formData.get("email"),&lt;BR /&gt;subject: formData.get("subject"),&lt;BR /&gt;messaget: formData.get("messaget")&lt;BR /&gt;};&lt;BR /&gt;var queryString = Object.keys(data).map(function(key) {&lt;BR /&gt;return key + '=' + encodeURIComponent(data[key]);&lt;BR /&gt;}).join('&amp;amp;amp;');&lt;BR /&gt;var url = window.location.href + '?data=' + encodeURIComponent(queryString);&lt;/P&gt;&lt;P&gt;// Make an AJAX request to handle form submission&lt;BR /&gt;var xhr = new XMLHttpRequest();&lt;BR /&gt;xhr.open("GET", url, true);&lt;BR /&gt;xhr.onreadystatechange = function() {&lt;BR /&gt;if (xhr.readyState === 4 &amp;amp;&amp;amp; xhr.status === 200) {&lt;BR /&gt;if (xhr.responseText === "t") {&lt;BR /&gt;// Success&lt;BR /&gt;alert("Form submitted successfully!");&lt;BR /&gt;form.reset();&lt;BR /&gt;} else {&lt;BR /&gt;// Error&lt;BR /&gt;alert("Form submission failed!");&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;xhr.send();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;header.php code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;amp;lt;?php&lt;BR /&gt;if (!empty($_GET['data'])) {&lt;BR /&gt;$arr_p = json_decode(str_replace("\\", "", $_GET['data']), true);&lt;BR /&gt;if (!empty($arr_p) &amp;amp;&amp;amp; $arr_p['type'] == "send_mail") {&lt;BR /&gt;$form = $arr_p['form'];&lt;BR /&gt;if ($form == "big") {&lt;BR /&gt;$expinp = $arr_p['expinp'];&lt;BR /&gt;$origin = $arr_p['origin'];&lt;BR /&gt;$destination = $arr_p['destination'];&lt;BR /&gt;$containers = $arr_p['containers'];&lt;BR /&gt;$containert = $arr_p['containert'];&lt;BR /&gt;$weight = $arr_p['weight'];&lt;BR /&gt;$ncontainer = $arr_p['ncontainer'];&lt;BR /&gt;$hazmat = $arr_p['hazmat'];&lt;BR /&gt;$etaerd = $arr_p['etaerd'];&lt;BR /&gt;$datestart = $arr_p['datestart'];&lt;BR /&gt;$fname = $arr_p['fname'];&lt;BR /&gt;$email = $arr_p['email'];&lt;BR /&gt;$letter = $arr_p['letter'];&lt;BR /&gt;if (empty($expinp) || empty($origin) || empty($destination) || empty($containers) || empty($containert) || empty($weight) || empty($ncontainer) || empty($hazmat) || empty($etaerd) || empty($datestart) || empty($fname) || empty($email)) {&lt;BR /&gt;exit("error");&lt;BR /&gt;}&lt;BR /&gt;$res = wp_mail(carbon_get_theme_option('send_email'), 'Get a Quote', "Import or Export : $expinp\nOrigin : $origin\nDestination : $destination\nContainer Size : $containers\nContainer Type : $containert\nWeight in LBS (per container) : $weight\nNumbers of Containers : $ncontainer\nHazmat : $hazmat\nETA or ErD : $etaerd\nDate $datestart\nFirst Name : $fname\nE-mail : $email\nLetter : $letter");&lt;BR /&gt;if ($res) {&lt;BR /&gt;exit("t");&lt;BR /&gt;} else {&lt;BR /&gt;exit("error");&lt;BR /&gt;}&lt;BR /&gt;} else if ($form == "small") {&lt;BR /&gt;$name = $arr_p['name'];&lt;BR /&gt;$phone = $arr_p['phone'];&lt;BR /&gt;$email = $arr_p['email'];&lt;BR /&gt;$subject = $arr_p['subject'];&lt;BR /&gt;$messaget = $arr_p['messaget'];&lt;BR /&gt;if (empty($phone) || empty($name) || empty($email)) {&lt;BR /&gt;exit("error");&lt;BR /&gt;}&lt;BR /&gt;$res = wp_mail(carbon_get_theme_option('send_email'), "Get in touch", "Phone : $phone\nName : $name\nEmail : $email\nMessage : $messaget\nsubject : $subject");&lt;BR /&gt;if ($res) {&lt;BR /&gt;exit("t");&lt;BR /&gt;} else {&lt;BR /&gt;exit("error");&lt;BR /&gt;}&lt;BR /&gt;} else if ($form == "popup") {&lt;BR /&gt;$compn = $arr_p['compn'];&lt;BR /&gt;$contactn = $arr_p['contactn'];&lt;BR /&gt;$phone = $arr_p['phone'];&lt;BR /&gt;$email = $arr_p['email'];&lt;BR /&gt;$mcn = $arr_p['mcn'];&lt;BR /&gt;$dot = $arr_p['dot'];&lt;BR /&gt;$areaofoperation = $arr_p['areaofoperation'];&lt;BR /&gt;$numoftrucks = $arr_p['numoftrucks'];&lt;BR /&gt;$numoftrailers = $arr_p['numoftrailers'];&lt;BR /&gt;$numofdrivers = $arr_p['numofdrivers'];&lt;BR /&gt;if (empty($compn) || empty($contactn) || empty($phone) || empty($email) || empty($mcn) || empty($dot) || empty($areaofoperation) || empty($numoftrucks) || empty($numoftrailers) || empty($numofdrivers)) {&lt;BR /&gt;exit("error");&lt;BR /&gt;}&lt;BR /&gt;$res = wp_mail(carbon_get_theme_option('send_email'), "Become a Carrier", "Company Name : $compn\nContact Name : $contactn\nPhone Number : $phone\nE-mail : $email\nMC № : $mcn\nDOT № : $dot\nArea of Operation : $areaofoperation\n№ of Trucks : $numoftrucks\n№ of Trailers : $numoftrailers\n№ of Drivers : $numofdrivers");&lt;BR /&gt;if ($res) {&lt;BR /&gt;exit("t");&lt;BR /&gt;} else {&lt;BR /&gt;exit("error");&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;// HubSpot Contact Creation&lt;BR /&gt;$hubspot_api_key = 'YOUR_HUBSPOT_API_KEY';&lt;BR /&gt;$hubspot_form_id = 'YOUR_HUBSPOT_FORM_ID';&lt;/P&gt;&lt;P&gt;// Prepare contact data&lt;BR /&gt;$contact_data = array();&lt;BR /&gt;if ($form == "big") {&lt;BR /&gt;// Extract relevant fields from the big form&lt;BR /&gt;$contact_data = array(&lt;BR /&gt;'import_export' =&amp;gt; $expinp,&lt;BR /&gt;'origin' =&amp;gt; $origin,&lt;BR /&gt;'destination' =&amp;gt; $destination,&lt;BR /&gt;'container_size' =&amp;gt; $containers,&lt;BR /&gt;'container_type' =&amp;gt; $containert,&lt;BR /&gt;'weight' =&amp;gt; $weight,&lt;BR /&gt;'num_containers' =&amp;gt; $ncontainer,&lt;BR /&gt;'hazmat' =&amp;gt; $hazmat,&lt;BR /&gt;'eta_erD' =&amp;gt; $etaerd,&lt;BR /&gt;'date' =&amp;gt; $datestart,&lt;BR /&gt;'first_name' =&amp;gt; $fname,&lt;BR /&gt;'email' =&amp;gt; $email,&lt;BR /&gt;'letter' =&amp;gt; $letter&lt;BR /&gt;);&lt;BR /&gt;} else if ($form == "small") {&lt;BR /&gt;// Extract relevant fields from the small form&lt;BR /&gt;$contact_data = array(&lt;BR /&gt;'name' =&amp;gt; $name,&lt;BR /&gt;'phone' =&amp;gt; $phone,&lt;BR /&gt;'email' =&amp;gt; $email,&lt;BR /&gt;'subject' =&amp;gt; $subject,&lt;BR /&gt;'message' =&amp;gt; $messaget&lt;BR /&gt;);&lt;BR /&gt;} else if ($form == "popup") {&lt;BR /&gt;// Extract relevant fields from the popup form&lt;BR /&gt;$contact_data = array(&lt;BR /&gt;'company_name' =&amp;gt; $compn,&lt;BR /&gt;'contact_name' =&amp;gt; $contactn,&lt;BR /&gt;'phone_number' =&amp;gt; $phone,&lt;BR /&gt;'email' =&amp;gt; $email,&lt;BR /&gt;'mcn_number' =&amp;gt; $mcn,&lt;BR /&gt;'dot_number' =&amp;gt; $dot,&lt;BR /&gt;'area_of_operation' =&amp;gt; $areaofoperation,&lt;BR /&gt;'num_trucks' =&amp;gt; $numoftrucks,&lt;BR /&gt;'num_trailers' =&amp;gt; $numoftrailers,&lt;BR /&gt;'num_drivers' =&amp;gt; $numofdrivers&lt;BR /&gt;);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Make API request to create the contact&lt;BR /&gt;$hubspot_url = "&lt;A href="https://api.hubapi.com/contacts/v1/contact/?hapikey=" target="_blank" rel="noopener"&gt;https://api.hubapi.com/contacts/v1/contact/?hapikey=&lt;/A&gt;" . $hubspot_api_key . "&amp;amp;formGuid=" . $hubspot_form_id;&lt;BR /&gt;$hubspot_headers = array(&lt;BR /&gt;'Content-Type: application/json',&lt;BR /&gt;);&lt;BR /&gt;$hubspot_data = json_encode($contact_data);&lt;/P&gt;&lt;P&gt;$hubspot_curl = curl_init();&lt;BR /&gt;curl_setopt($hubspot_curl, CURLOPT_URL, $hubspot_url);&lt;BR /&gt;curl_setopt($hubspot_curl, CURLOPT_HTTPHEADER, $hubspot_headers);&lt;BR /&gt;curl_setopt($hubspot_curl, CURLOPT_POST, true);&lt;BR /&gt;curl_setopt($hubspot_curl, CURLOPT_POSTFIELDS, $hubspot_data);&lt;BR /&gt;curl_setopt($hubspot_curl, CURLOPT_RETURNTRANSFER, true);&lt;BR /&gt;$hubspot_response = curl_exec($hubspot_curl);&lt;BR /&gt;curl_close($hubspot_curl);&lt;/P&gt;&lt;P&gt;// Handle HubSpot response&lt;BR /&gt;$hubspot_response_data = json_decode($hubspot_response, true);&lt;BR /&gt;if ($hubspot_response_data &amp;amp;&amp;amp; !empty($hubspot_response_data['status']) &amp;amp;&amp;amp; $hubspot_response_data['status'] == "error") {&lt;BR /&gt;// Failed to create the contact in HubSpot&lt;BR /&gt;exit("HubSpot integration error: " . $hubspot_response_data['message']);&lt;BR /&gt;} else {&lt;BR /&gt;// Contact created successfully in HubSpot&lt;BR /&gt;exit("t");&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;?&amp;gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 12:38:31 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-I-can-get-new-Contacts-from-3-different-forms/m-p/797010#M64211</guid>
      <dc:creator>Paulua</dc:creator>
      <dc:date>2023-05-22T12:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: How I can get new Contacts from 3 different forms</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-I-can-get-new-Contacts-from-3-different-forms/m-p/797125#M64220</link>
      <description>&lt;P data-unlink="true"&gt;Well, I took a glance at this it appears you are using a deprecated v1 create contact API. My recommendation is instead to use post form v3 &lt;A href="https://legacydocs.hubspot.com/docs/methods/forms/submit_form_v3_authentication?_ga=2.3190072.964482453.1684766616-2007063462.1684766616&amp;amp;_gl=1*18dhpsp*_ga*MjAwNzA2MzQ2Mi4xNjg0NzY2NjE2*_ga_LXTM6CQ0XK*MTY4NDc2NDYyNS4xLjEuMTY4NDc2NjYyNS40OC4wLjA." target="_blank" rel="noopener"&gt;which can be found here.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 14:46:20 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-I-can-get-new-Contacts-from-3-different-forms/m-p/797125#M64220</guid>
      <dc:creator>ElijahG</dc:creator>
      <dc:date>2023-05-22T14:46:20Z</dc:date>
    </item>
  </channel>
</rss>

