136 lines
4.4 KiB
PHP
136 lines
4.4 KiB
PHP
<?
|
|
if (\S::get('action') == 'pobierz_ebook_form_send') {
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
$hubspot_url = "https://api.hsforms.com/submissions/v3/integration/submit/7094950/325e9e91-e66a-4423-83f7-39d918182f55";
|
|
$hubspotutk = isset($_COOKIE['hubspotutk']) ? $_COOKIE['hubspotutk'] : null;
|
|
|
|
// Prepare data
|
|
$postData = [
|
|
'fields' => [
|
|
[
|
|
'name' => 'email',
|
|
'value' => $_POST['email'],
|
|
],
|
|
[
|
|
'name' => 'firstname',
|
|
'value' => $_POST['firstname'],
|
|
],
|
|
[
|
|
'name' => 'lastname',
|
|
'value' => $_POST['lastname'],
|
|
],
|
|
[
|
|
'name' => 'phone',
|
|
'value' => $_POST['phone'],
|
|
]
|
|
],
|
|
'context' => [
|
|
'hutk' => $hubspotutk,
|
|
'pageUri' => 'https://zaufane.pl/',
|
|
'pageName' => 'zaufane.pl - ebook'
|
|
],
|
|
'legalConsentOptions' => [
|
|
'consent' => [
|
|
'content' => 'By submitting this form, you agree that we may use the data you provide to contact you with information related to your request/submission and the relevant LinkedIn product. If you are a LinkedIn member, you can control the messages you receive from LinkedIn in your settings. If you are a guest, you can unsubscribe from LinkedIn marketing emails at any time by clicking the unsubscribe link in the email. To learn more, see LinkedIn\'s Privacy Policy.',
|
|
'consentToProcess' => true,
|
|
'text' => 'I agree to the processing of my personal data by LinkedIn.',
|
|
'communications' => [
|
|
[
|
|
'value' => true,
|
|
'subscriptionTypeId' => 8383894,
|
|
'text' => 'I agree to receive marketing communications from LinkedIn.'
|
|
]
|
|
]
|
|
]
|
|
]
|
|
];
|
|
|
|
$jsonData = json_encode($postData);
|
|
|
|
// Initialize cURL
|
|
$ch = curl_init($hubspot_url);
|
|
|
|
// Set cURL options
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
|
|
|
|
|
|
|
|
// Execute cURL request
|
|
$response = curl_exec($ch);
|
|
|
|
// Check for errors
|
|
if ($response === false) {
|
|
$error = curl_error($ch);
|
|
echo "cURL Error: $error";
|
|
} else {
|
|
// Decode response
|
|
$responseData = json_decode($response, true);
|
|
|
|
if (isset($responseData['redirectUri'])) {
|
|
header("Location: " . $responseData['redirectUri']);
|
|
exit();
|
|
} else {
|
|
echo "<div id='custom-form-response'><p>" . $response . '</p></div>';
|
|
}
|
|
}
|
|
|
|
// Close cURL session
|
|
curl_close($ch);
|
|
?>
|
|
<script class="footer">
|
|
$(document).ready(function() {
|
|
$('#custom-form').remove()
|
|
})
|
|
</script>
|
|
<?
|
|
|
|
}
|
|
|
|
// echo 'Form sent';
|
|
}
|
|
?>
|
|
<form method="POST" action="/pobierz-ebook" id="custom-form">
|
|
<input type="hidden" name="action" value="pobierz_ebook_form_send">
|
|
|
|
<div class="f-row">
|
|
<div class="tile">
|
|
<input type="email" name="email" id="form-email" placeholder="">
|
|
<label for="form-email">Email</label>
|
|
</div>
|
|
<div class="tile">
|
|
<input type="text" name="firstname" id="form-firstname" placeholder="">
|
|
<label for="form-firstname">Imię</label>
|
|
</div>
|
|
<div class="tile">
|
|
<input type="text" name="lastname" id="form-lastname" placeholder="">
|
|
<label for="form-lastname">Nazwisko</label>
|
|
</div>
|
|
<div class="tile">
|
|
<input type="text" name="phone" id="form-phone" placeholder="">
|
|
<label for="form-phone">Numer telefonu</label>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="checkbox-row">
|
|
<input type="checkbox" name="" id="checkbox-1" require>
|
|
<label for="checkbox-1">Wyrażam zgodę na otrzymywanie innych powiadomień od firmy ... <a href="#" id="info-for-checkbox-1">Więcej</a></label>
|
|
</div>
|
|
|
|
<button type="submit" class="btn1">Otrzymaj wycenę</button>
|
|
</form>
|
|
|
|
<script class="footer">
|
|
$(document).ready(function() {
|
|
$('body').on('click', '#info-for-checkbox-1', function (e) {
|
|
e.preventDefault()
|
|
$.alert({
|
|
title: '',
|
|
content: 'Wyrażam zgodę na otrzymywanie innych powiadomień od firmy Zaufane.pl. Aby zapewnić Państwu żądane treści, musimy przechowywać i przetwarzać Państwa dane osobowe. Jeśli wyrażają Państwo zgodę na przechowywanie Państwa danych osobowych w tym celu, prosimy zaznaczyć poniższe pole wyboru.',
|
|
});
|
|
})
|
|
});
|
|
</script>
|