Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-Type: text/html; charset=iso-8859-2');
- global $post;
- if($_POST)
- {
- $to_email = "pablobbbb@wp.pl"; //Recipient email, Replace with own email here
- //check if its an ajax request, exit if not
- if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
- $output = json_encode(array( //create JSON data
- 'type'=>'error',
- 'text' => 'Sorry Request must be Ajax POST'
- ));
- die($output); //exit script outputting json data
- }
- //Sanitize input data using PHP filter_var().
- $user_name = filter_var($_POST["user_name"], FILTER_SANITIZE_STRING);
- $user_surname = filter_var($_POST["user_surname"], FILTER_SANITIZE_STRING);
- $user_email = filter_var($_POST["user_email"], FILTER_SANITIZE_EMAIL);
- $phone_number = filter_var($_POST["phone_number"], FILTER_SANITIZE_NUMBER_INT);
- $street = filter_var($_POST["street"], FILTER_SANITIZE_STRING);
- $streetnr = filter_var($_POST["streetnr"], FILTER_SANITIZE_STRING);
- $city = filter_var($_POST["city"], FILTER_SANITIZE_STRING);
- $zipcode = filter_var($_POST["zipcode"], FILTER_SANITIZE_STRING);
- $rightnr = filter_var($_POST["rightnr"], FILTER_SANITIZE_STRING);
- $nip = filter_var($_POST["nip"], FILTER_SANITIZE_NUMBER_INT);
- $company = filter_var($_POST["company"], FILTER_SANITIZE_STRING);
- $message = $_POST["message"];
- $subject = "Nowe zgłoszenie na szkolenia od " . $user_name . " " . $user_surname;
- $sender_subject = "Potwierdzenie zgłoszenia na szkolenia Poldent.pl";
- $test = mb_convert_encoding('łęśćłżą', 'HTML-ENTITIES', 'UTF-8');
- //$message = filter_var($_POST["msg"], FILTER_SANITIZE_STRING);
- $checkbox = $_POST['checkbox'];
- $checkbox2 = $_POST['checkbox2'];
- $checkbox3 = $_POST['checkbox3'];
- $school = $_POST['school'];
- $schoolbody = '';
- foreach ($school as $s)
- {
- $data = @json_decode($s['value']);
- $schoolbody .= "Nazwa szkolenia: ".$data->item_name."\r\nData szkolenia: ".$data->item_number."\r\nGodzina szkolenia: ".$data->item_hour."\r\nKoszt szkolenia: ".$data->amount." zł‚\r\nProwadzący szkolenie: ".$data->item_lect."\r\nLiczba punktów edukacyjnych: ".$data->item_point." \r\n\r\n";
- $schoolbname .= " ".$data->item_name." - ".$data->item_number." ";
- }
- $person = $_POST['person'];
- $personbody = '';
- foreach ($person as $p)
- {
- $data = @json_decode($p['value']);
- $personbody .= $data->item_person.',';
- }
- //$title = get_the_title();
- //additional php validation
- //additional php validation
- $rule = '';
- if(($checkbox3 =="false")){
- $rule = 'Nie';
- } else if(($checkbox3 =="true")){
- $rule = 'Tak';
- }
- if(strlen($user_name)<2){ // If length is less than 4 it will output JSON error.
- $output = json_encode(array('type'=>'error', 'text' => 'Wpisane pole "Imię" jest za krótkie lub puste.'));
- die($output);
- }
- if(strlen($user_surname)<2){ // If length is less than 4 it will output JSON error.
- $output = json_encode(array('type'=>'error', 'text' => 'Wpisane pole "Nazwisko" jest za krótkie lub puste.'));
- die($output);
- }
- if(!filter_var($user_email, FILTER_VALIDATE_EMAIL)){ //email validation
- $output = json_encode(array('type'=>'error', 'text' => 'Proszę wprowadzić poprawny adres e-mail.'));
- die($output);
- }
- if(strlen($phone_number)<7){ // If length is less than 4 it will output JSON error.
- $output = json_encode(array('type'=>'error', 'text' => 'Podany numer jest błądy lub za krótki.'));
- die($output);
- }
- if($_POST["choice"] == 1) {
- if(strlen($company)<2){
- // If length is less than 4 it will output JSON error.
- $output = json_encode(array('type'=>'error', 'text' => 'Nazwa firmy jest za krótka.'));
- die($output);
- }
- if(strlen($nip)<8){ // If length is less than 4 it will output JSON error.
- $output = json_encode(array('type'=>'error', 'text' => 'Numer NIP jest błędny.'));
- die($output);
- }
- }
- if(strlen($street)<3){ // If length is less than 4 it will output JSON error.
- $output = json_encode(array('type'=>'error', 'text' => 'Nazwa ulicy jest za krótka.'));
- die($output);
- }
- if(strlen($streetnr)<1){ // If length is less than 4 it will output JSON error.
- $output = json_encode(array('type'=>'error', 'text' => 'Numer budynku/lokalu jest za krotki.'));
- die($output);
- }
- if(strlen($city)<3){ // If length is less than 4 it will output JSON error.
- $output = json_encode(array('type'=>'error', 'text' => 'Nazwa miasta jest za krótka'));
- die($output);
- }
- if(strlen($zipcode)<5){ // If length is less than 4 it will output JSON error.
- $output = json_encode(array('type'=>'error', 'text' => 'Błędny kod pocztowy.'));
- die($output);
- }
- if(strlen($rightnr)<2){ // If length is less than 4 it will output JSON error.
- $output = json_encode(array('type'=>'error', 'text' => 'Numer do wykonywania zawodu jest za krótki.'));
- die($output);
- }
- if(($checkbox =="false")){
- $output = json_encode(array('type'=>'error', 'text' => 'Brak akceptacji regulaminów szkoleń'));
- die($output);
- }
- if(($checkbox2 =="false")){
- $output = json_encode(array('type'=>'error', 'text' => 'Brak akceptacji na przetwarzanie danych osobowych w celu realizacji umowy na uczestnictwo w kursie.'));
- die($output);
- }
- //if(strlen($message)<3){ //check emtpy message
- // $output = json_encode(array('type'=>'error', 'text' => 'Zbyt krótka wiadomość. Wpisz więcej!'));
- // die($output);
- //}
- //email body
- $message_body = "
- <html>
- <head>
- <title>Test</title>
- </head>
- <body>
- <p>śłężę</p>
- <table>
- <tr>
- <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
- </tr>
- <tr>
- <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
- </tr>
- <tr>
- <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
- </tr>
- </table>
- </body>
- </html>
- \r\nImię i nazwisko : ".$user_name." ".$user_surname.",
- \r\nEmail : ".$user_email."
- \r\nNumer telefonu : ". $phone_number ."
- \r\nNazwa firmy : ".$company."
- \r\nNIP firmy : ".$nip."
- \r\nUlica : ".$street." ".$streetnr."
- \r\nMiasto : ".$zipcode." ".$city."
- \r\nNumer prawa do wykonywania zawodu : ".$rightnr."
- \r\nTreść Wiadomości : ".$message."
- \r\nPotwierdzenie zgody na przetwarzanie informacji: ".$rule."
- \r\nSzkolenia:\r\n".$schoolbody."
- \r\nTest: ".$test;
- $sender_message_body = "
- \r\n Uwaga! Po zapisie na szkolenie powinni Państwo otrzymać telefon lub e-mail potwierdzający zapis na dane szkolenie. W przypadku braku kontaktu z naszej strony – prosimy o kontakt telefoniczny pod nr 22 3517668.
- \r\n ".$choice."
- \r\nWitaj ".$user_name." ".$user_surname."
- \r\nDziękujemy za zapisanie się na szkolenie.
- \r\nPoniżej znajduje się lista szkoleń, na które zostałeś zapisany.
- \r\n
- \r\nSzkolenia:
- \r\n".$schoolbody. "
- \r\nWpłatę za szkolenia (jeśli nie jest zaznaczone inaczej w opisie szkolenia) prosimy uiścić na poniższe konto bankowe:
- \r\nPEKAO 64 1240 6175 1111 0010 3915 9844
- \r\nW tytule przelewu prosimy wpisać: imię, nazwisko, datę szkolenia, miejsce szkolenia.
- \r\nWpłat na szkolenia prosimy dokonywać maksymalnie na 2 tygodnie przed datą szkolenia.
- \r\nW razie jakichkolwiek pytań dotyczących szkoleń prosimy o kontakt pod adresem:
- \r\nszkolenia@poldent.pl lub pod tel. 22 351 76 68
- \r\nDziękujemy i do zobaczenia na szkoleniu,
- \r\nZespół Poldent.pl
- ";
- function utf8mail($to,$subject,$message_body,$from_name="x",$from_a = "info@x.com", $reply="info@x.com")
- {
- $subject= "=?utf-8?b?".base64_encode($subject)."?=";
- $headers = "MIME-Version: 1.0\r\n";
- $headers.= "From: =?utf-8?b?".base64_encode($from_name)."?= <".$from_a.">\r\n";
- $headers.= "Content-Type: text/plain;charset=utf-8\r\n";
- $headers.= "Reply-To: $reply\r\n";
- $headers.= "X-Mailer: PHP/" . phpversion();
- $BodyReceiver = mail($to, $subject, $message_body, $headers);
- }
- if(!$BodyReceiver)
- {
- //If mail couldn't be sent output error. Check your PHP email configuration (if it ever happens)
- $output = json_encode(array('type'=>'error', 'text' => 'Could not send mail! Please check your PHP mail configuration.'));
- die($output);
- }else{
- $output = json_encode(array('type'=>'message', 'text' => 'Witaj '.$user_name .' '.$user_surname.'. Dziękujemy za wypełnienie formularza.'));
- die($output);
- }
- /*
- //proceed with PHP email.
- $headers = 'MIME-Version: 1.0' . "\r\n";
- $headers .= 'Content-type: text/html; charset=iso-8859-2' . "\r\n";
- $headers = 'From: '.$user_email.'' . "\r\n" .
- 'Reply-To: '.$user_email.'' . "\r\n" .
- 'X-Mailer: PHP/' . phpversion();
- $sender_headers = 'From: '.$to_email.'' . "\r\n" .
- 'Reply-To: '.$to_email.'' . "\r\n" .
- 'X-Mailer: PHP/' . phpversion();
- $BodyReceiver = mail('pablobbbb@wp.pl', $subject, $message_body, $headers);
- $BodySender = mail($user_email, $sender_subject, $sender_message_body, $sender_headers);
- if(!$BodyReceiver)
- {
- //If mail couldn't be sent output error. Check your PHP email configuration (if it ever happens)
- $output = json_encode(array('type'=>'error', 'text' => 'Could not send mail! Please check your PHP mail configuration.'));
- die($output);
- }else{
- $output = json_encode(array('type'=>'message', 'text' => 'Witaj '.$user_name .' '.$user_surname.'. Dziękujemy za wypełnienie formularza.'));
- die($output);
- }*/
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement