Add form send

This commit is contained in:
Roman Pyrih
2025-10-07 15:07:41 +02:00
parent 420950fbec
commit 3db028b0d4
2 changed files with 128 additions and 15 deletions

View File

@@ -462,4 +462,72 @@ if ( \S::get('action') == 'send-contact-form-new' and \S::get( 'token' ) == \S::
}
header( 'Location: ' . $_SERVER['REQUEST_URI'] );
exit;
}
if ( \S::get('action') == 'send-partner-form-new' and \S::get( 'token' ) == \S::get_session( 'partner-form-token' ) and !\S::get( 'website' ) )
{
if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
\S::alert( "Weryfikacja reCaptcha nie powiodła się. Proszę spróbować ponownie." );
header( 'Location: ' . $_SERVER['REQUEST_URI'] );
exit;
}
$secretKey = "6LfaovglAAAAAAz84QLdbONodP1yJUpSOVTnFMt4";
$ip = $_SERVER['REMOTE_ADDR'];
// post request to server
$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($secretKey) . '&response=' . urlencode($captcha);
$response = file_get_contents($url);
$responseKeys = json_decode($response,true);
// should return JSON with success as true
if($responseKeys["success"]) {
if (
strposa( \S::get( 'company' ), $spam_words ) === false
and
\S::get( 'company_address' )
and
\S::get( 'phone' )
and
\S::get( 'email' )
and
strposa( \S::get( 'name' ), $spam_words ) === false
and
strposa( \S::get( 'surname' ), $spam_words ) === false
){
$aggrement1 = \S::get('aggrement1') === 'on' ? 'Tak' : 'Nie';
$aggrement2 = \S::get('aggrement2') === 'on' ? 'Tak' : 'Nie';
$text = '<p><b>Rodzaj Partnera biznesowego:</b> ' . \S::get('partner-type') . '</p>';
$text .= '<p><b>Nazwa Firmy:</b> ' . \S::get('company') . '</p>';
$text .= '<p><b>Adres firmy:</b> ' . \S::get('company_address') . '</p>';
$text .= '<p><b>Telefon:</b> ' . \S::get('phone') . '</p>';
$text .= '<p><b>Adres e-mail:</b> ' . \S::get('email') . '</p>';
$text .= '<p><b>Imię:</b> ' . \S::get('name') . '</p>';
$text .= '<p><b>Nazwisko:</b> ' . \S::get('surname') . '</p>';
$text .= '<p><b>Interesują mnie:</b> ' . \S::get('interesting-me') . '</p>';
$text .= '<p><b>Wyrażam zgodę na przetwarzanie moich danych osobowych podanych przeze mnie powyżej w celu przygotowania stosownej oferty:</b> ' . $aggrement1 . '</p>';
$text .= '<p><b>Wyrażam zgodę na przetwarzanie moich danych osobowych podanych przeze mnie powyżej w celu otrzymywania materiałów reklamowych:</b> ' . $aggrement2 . '</p>';
$text .= '<p style="font-size: 13px; color: #ccc; margin-top: 50px;"><b>Wysłano:</b> ' . date( 'Y-m-d H:i:s' ) . '</p>';
if ( \S::send_email( 'marketing@vidok.com', 'Wiadomość ze strony vidok.com', $text, \S::get('email'), $files_to_send ) )
{
// send copy to k.zarzyczny@vidok.com
\S::send_email( 'k.zarzyczny@vidok.com', 'Wiadomość ze strony vidok.com', $text, \S::get('email'), $files_to_send );
\S::send_email( 'arkuszevidok@vidok.com', 'Wiadomość ze strony vidok.com', $text, \S::get('email'), $files_to_send );
\S::alert( \S::lang('wiadomosc-zostala-wyslana' ) );
header('Location: ' . $_SERVER['REQUEST_URI'] . '?form_sent=1');
exit;
}
else
\S::alert( \S::lang('wiadomosc-niezostala-wyslana' ) );
}
else
\S::alert( \S::lang('wiadomosc-niezostala-wyslana' ) );
} else {
\S::alert( "Jesteś robotem!" );
}
header( 'Location: ' . $_SERVER['REQUEST_URI'] );
exit;
}

View File

@@ -1,3 +1,5 @@
<? \S::set_session('partner-form-token', bin2hex(random_bytes(32))); ?>
<style>
html {
scroll-behavior: smooth;
@@ -19,6 +21,9 @@
.custom-checkbox .custom-control-label::before {
border-radius: 5rem;
}
.custom-checkbox .custom-control-label::after {
display: none !important;
}
.benefits-card {
border: 1px solid #dfdfdf;
@@ -194,6 +199,19 @@
transform: translate(calc(-50% - 0.5rem));
}
}
.partner-contact-form .form-actions{
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
flex-wrap: wrap;
gap: 15px;
}
.partner-contact-form .form-info div{
font-size: 15px;
margin-top: 30px;
}
</style>
<div class="main-page" style="overflow-x: hidden; max-width: 100%">
@@ -247,7 +265,6 @@
<div style="display: flex; justify-content: center; gap: 1rem">
<div class="c-btn-contact-box btn-contact-box-select2">
<select class="btn-contact-us" id="select-country" name="country" onchange="swapCountry(true)">
<option value="" disabled selected hidden>Kraj</option>
<option value="Polska">Polska</option>
<option value="Niemcy">Niemcy</option>
<option value="Stany Zjednoczone">Stany Zjednoczone</option>
@@ -307,10 +324,21 @@
</div>
</div>
<form class="col-lg m-4 partner-contact-form" style="border-radius: 30px; background: #F8F7F6">
<!-- <form class="col-lg m-4 partner-contact-form" style="border-radius: 30px; background: #F8F7F6"> -->
<form
method="POST"
action=""
enctype="multipart/form-data"
id="partner-form-new"
class="col-lg m-4 partner-contact-form"
style="border-radius: 30px; background: #F8F7F6"
>
<input type="hidden" name="action" value="send-partner-form-new">
<input type="hidden" name="token" value="<?= \S::get_session('partner-form-token'); ?>">
<input type="hidden" name="website" value="">
<div class="row mb-2">
<div class="col">
<select class="form-control" id="select-partner-type">
<select name="partner-type" class="form-control" id="select-partner-type">
<option value="" disabled selected hidden>Rodzaj Partnera biznesowego</option>
<option value="Deweloper">Deweloper</option>
<option value="Firma budowlana">Firma budowlana</option>
@@ -322,35 +350,35 @@
</div>
<div class="row mb-2">
<div class="col">
<input class="form-control rounded-full border-none" placeholder="Nazwa firmy *" require/>
<input class="form-control rounded-full border-none" name="company" placeholder="Nazwa firmy *" required/>
</div>
</div>
<div class="row mb-5">
<div class="col">
<input class="form-control rounded-full border-none" placeholder="Adres firmy *" require/>
<input class="form-control rounded-full border-none" name="company_address" placeholder="Adres firmy *" required/>
</div>
</div>
<div class="row mb-2">
<div class="col">
<input class="form-control rounded-full border-none" placeholder="Telefon *" require/>
<input class="form-control rounded-full border-none" name="phone" placeholder="Telefon *" required/>
</div>
<div class="col">
<input class="form-control rounded-full border-none" placeholder="Adres e-mail *" require/>
<input class="form-control rounded-full border-none" name="email" placeholder="Adres e-mail *" required/>
</div>
</div>
<div class="row mb-2">
<div class="col">
<input class="form-control rounded-full border-none" placeholder="Imię *" require/>
<input class="form-control rounded-full border-none" name="name" placeholder="Imię *" required/>
</div>
<div class="col">
<input class="form-control rounded-full border-none" placeholder="Nazwisko *" require/>
<input class="form-control rounded-full border-none" name="surname" placeholder="Nazwisko *" required/>
</div>
</div>
<div class="row row_last">
<div class="col">
<select class="form-control" id="select-interesting-me">
<select name="interesting-me" class="form-control" id="select-interesting-me">
<option value="" disabled selected hidden>Interesują mnie ...</option>
<option value="Okna">Okna</option>
<option value="Drzwi">Drzwi</option>
@@ -381,26 +409,43 @@
<!-- <div class="m-2">
<textarea placeholder="Opis zgłoszenia" class="form-control border-none" style="height: 8rem"></textarea>
</div> -->
<div class="custom-control custom-checkbox m-2 rounded-full" style="font-size: 10px">
<input type="checkbox" class="custom-control-input" id="Aggrement1" />
<div class="custom-control custom-checkbox m-2 rounded-full" style="font-size: 12px">
<input type="checkbox" name="aggrement1" class="custom-control-input" id="Aggrement1" />
<label class="custom-control-label" for="Aggrement1" style="cursor: pointer">
Wyrażam zgodę na przetwarzanie moich danych osobowych podanych przeze mnie powyżej w celu przygotowania
stosownej oferty.
</label>
</div>
<div class="custom-control custom-checkbox m-2 rounded-full" style="font-size: 10px">
<input type="checkbox" class="custom-control-input" id="Aggrement2" />
<div class="custom-control custom-checkbox m-2 mb-5 rounded-full" style="font-size: 12px">
<input type="checkbox" name="aggrement2" class="custom-control-input" id="Aggrement2" />
<label class="custom-control-label" for="Aggrement2" style="cursor: pointer">
Wyrażam zgodę na przetwarzanie moich danych osobowych podanych przeze mnie powyżej w celu otrzymywania
materiałów reklamowych.
</label>
</div>
<div style="text-align: right">
<div class="form-actions">
<div class="g-recaptcha" data-sitekey="6LfaovglAAAAAAieLVC7i4xGkQA5ufXUbWLipSbp"></div>
<button type="submit" class="btn-submit">
WYŚLIJ
<img src="/upload/filemanager/icon/Vector.svg" alt="">
</button>
</div>
<div class="form-info">
<?php
if ($alert = \S::get_session('alert')) {
echo '<div>';
echo htmlspecialchars($alert);
echo '</div>';
$_SESSION['alert'] = null;
$_SESSION['alert-class'] = null;
unset($_SESSION['alert'], $_SESSION['alert-class']);
}
?>
</div>
</form>
</div>