Hello, i've got contact form which when i write msg in it with special signs for example polish signs or in english <'> <"> it sends just <?>
I have no idea why it could be happened my html file is coded ok utf-8 and here's php code
<
?php
$names = $_POST['names'];
$email = $_POST['email_address'];
$comment = $_POST['comment'];
$to ='szymondziewonski@gmail.com';
$message = "";
$message .= "Name: " . htmlspecialchars($names, ENT_QUOTES) . "<br>\n";
$message .= "Email: " . htmlspecialchars($email, ENT_QUOTES) . "<br>\n";
$message .= "Comment: " . htmlspecialchars($comment, ENT_QUOTES) . "<br>\n";
$lowmsg = strtolower($message);
$headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=UTF-8\r\n";
$headers .= "From: \"" . $names . "\" <" . $email . ">\r\n";
$headers .= "Reply-To: " . $email . "\r\n";
$message = utf8_decode($message); mail($to, "EMCD - Feedback", $message, $headers);
if ($message){
echo 'sent';
}else{
echo 'failed';
}
?>
I already tryed change this code :
$headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=UTF-8\r\n";
for:
$headers .= "Content-Type: text/plain; charset = \"UTF-8\";\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "\n";
and in this case does not even send message
Here's Ajax code:
<script>
$(document).ready(function(){
$('#submit-form').click(function(){
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var names = $('#contact-form [name="contact-names"]').val();
var email_address = $('#contact-form [name="contact-email"]').val();
var comment = $.trim($('#contact-form .contact-commnent').val());
var data_html ='' ;
if(names == ""){
$('#name-required').html('Your name is required.');
}else{
$('#name-required').html('');
}
if(email_address == ""){
$('#email-required').html('Your email is required.');
}else if(reg.test(email_address) == false){
$('#email-required').html('Invalid Email Address.');
}else{
$('#email-required').html('');
}
if(comment == ""){
$('#comment-required').html('Comment is required.');
}else{
$('#comment-required').html('');
}
if(comment != "" && names != "" && reg.test(email_address) != false){
data_html = "names="+ names + "&comment=" + comment + "&email_address="+ email_address;
//alert(data_html);
$.ajax({
type: 'POST',
url: 'contact-send.php',
data: data_html,
success: function(msg){
if (msg == 'sent'){
$('#success').html('Message sent!') ;
$('#contact-form [name="contact-names"]').val('');
$('#contact-form [name="contact-email"]').val('');
$('#contact-form .contact-commnent').val('');
}else{
$('#success').html('Mail Error. Please Try Again.!') ;
}
}
});
}
return false;
})
})
</script>
Here's html code:
<div class="form-wrapper">
<h1 id="success"></h1>
<h1>Feedback</h1>
<form id="contact-form" name="contact-form" method="POST">
<p>What is your name?</p><br/>
<p><input type="text" value="" name="contact-names" class="contact-names"/>
</p>
<h6 id="name-required"></h6><br/>
<p>Where can we email you back?</p><br/>
<p><input type="text" value="" name="contact-email" class="contact-email"/>
<h6 id="email-required"></h6></p><br/>
<p>What's on your mind?</p>
<p><br/>
<textarea class="contact-commnent" name="comments"></textarea>
<h6 id="comment-required"></h6></p><br/>
<p id="p-submit">
<input id="submit-form" class="submit-button" name="submit" type="submit" value="Submit"></p>
</form>
</div>
Would be appreciate if u could help !
cheers