Dziękuje.
Temat listu rzeczywiście się poprawił.
Ale treść jest źle kodowana.
Wydaje mi się, że chodzi o złe kodowanie AJAXU.
Próbowałem, wstawić kodowanie, ale wtedy blokuje się cały skrypt.
Obecnie plik contakt.php wygląda tak:
<?php
$subject = "=?UTF-8?B?".base64_encode("Wiadomość z mojej witryny od ".$_POST['name'])."?="; $naglowki ="From: name <email>\r\n".
"MIME-Version: 1.0" . "\r\n" .
"Content-type: text/html; charset=UTF-8" . "\r\n";
$to = "adres@firma.pl";
if (isset($_POST["name"]) && isset($_POST["email"]) && isset($_POST["message"])) { $content = "Nazywam sie: " . $_POST["name"] . "\r\n";
$content .= "Moj adres email: " . $_POST["email"] . "\r\n";
$content .= "Wiadomosc: " . "\r\n" . $_POST["message"];
if (mail($to, $subject, $content, $_POST["email"], $naglowki)) { "message" => "Listy wysłany.",
"sendstatus" => 1
);
echo json_encode
($result); } else {
"message" => "Niestety, coś jest nie tak.",
"sendstatus" => 0
);
echo json_encode
($result); }
}
?>
A plik contact.js
(function($){
$(document).ready(function() {
/* ---------------------------------------------- /*
* Contact form ajax
/* ---------------------------------------------- */
$('#contact-form').find('input,textarea').jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {
// additional error messages or events
},
submitSuccess: function($form, event) {
event.preventDefault();
// encoding:"UTF-8",
// dataType:"html",
// contentType: "text/plain; charset=UTF-8",
// dataType:"html", contentType: "text/plain; charset=UTF-8" } )
var submit = $('#contact-form submit');
var ajaxResponse = $('#contact-response');
var name = $("input#cname").val();
var email = $("input#cemail").val();
var message = $("textarea#cmessage").val();
$.ajax({
type: 'POST',
url: 'assets/php/contact.php',
// contentType: "application/json; charset=utf-8",
dataType: 'json',
data: {
name: name,
email: email,
message: message,
},
cache: false,
beforeSend: function(result) {
submit.append('<i class="fa fa-cog fa-spin"></i> Wait...');
},
success: function(result) {
if(result.sendstatus == 1) {
ajaxResponse.html(result.message);
$form.fadeOut(500);
} else {
ajaxResponse.html(result.message);
}
}
});
}
});
});
})(jQuery);
Ten post edytował preibx 27.07.2015, 06:52:40