I'm trying to make my contact form and i want it to show message (pop up, as a or anything else) when it's successfully sent or error when it can't be sent. But i don't know how to do it. I tried a lot of things and nothink worked for me.
Here is my html code:
<form id="contact-form" action="wyslij.php" method="POST">
<div class="form-group col-lg-6 col-md-6 col-xs-12">
<input type="text" name="name" value="" placeholder="Imie">
</div>
<div class="form-group col-lg-6 col-md-6 col-xs-12">
<input type="text" name="subject" value="" placeholder="Temat">
</div>
<div class="form-group col-lg-6 col-md-6 col-xs-12">
<input type="email" name="email" value="" placeholder="Email">
</div>
<div class="form-group col-lg-6 col-md-6 col-xs-12">
<input type="text" name="phone" value="" placeholder="Telefon">
</div>
<div class="form-group col-xs-12">
<textarea name="message" placeholder="Wiadomość"></textarea>
</div>
<div class="form-group col-xs-12 clearfix">
<input type="submit" class="pull-right" name="submit" value="Wyślij">
</div>
</form>
and here is my php code:
<?php
$owner_email = "kernelus1992#gmail.com"; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< tutaj wpisz adres email na który mają byc wysyłane maile
$headers = "From: ".$_POST["email"]."\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=utf-8\r\n";
$headers .= "Content-Transfer-Encoding: 8bit";
$subject = 'Wiadomość ze strony internetowej';
$subject = "=?utf-8?B?".base64_encode($subject)."?=";
$messageBody = "";
if($_POST['name']!='nope'){
$messageBody .= 'Imię i nazwisko: ' . $_POST["name"] ."\n";
$messageBody .= "\n";
}
if($_POST['email']!='nope'){
$mailnadawcy = $_POST['email'];
$messageBody .= 'Email: ' . $_POST['email'] . "\n";
$messageBody .= "\n";
}else{
$headers = '';
}
if($_POST['subject']!='nope'){
$messageBody .= 'Temat: ' . $_POST['subject'] . "\n";
$messageBody .= "\n";
}
if($_POST['phone']!='nope'){
$messageBody .= 'Telefon: ' . $_POST['phone'] . "\n";
$messageBody .= "\n";
}
if($_POST['message']!='nope'){
$messageBody .= 'Treść: ' . $_POST['message'] . "\n";
}
if($_POST["stripHTML"] == 'true'){
$messageBody = strip_tags($messageBody);
}
mail($owner_email, $subject, $messageBody, $headers);
?>
You can do it through AJAX.
<script>
$(document).ready(function(){
$("#contact-form").on("submit", function(e){
e.preventDefault();
dataString = jQuery('form#contact-form').serialize();
jQuery.ajax({
type: "POST",
url: "full_path/wyslij.php",
data: dataString,
success: function(data)
{
alert('Form successfully submitted.')
},
error: function(data)
{
alert('Form not submitted.')
}
});
});
});
</script>
Also form action should be removed:
<form id="contact-form" method="POST">
You will have to use javascript or jQuery if you don't want the page to reload, in jQuery for instance you can do:
$("#contact-form").on("submit", function(e){
e.preventDefault();
alert("Form submitted");
})
This doesn't handle validation, handling of input etc, I'd suggest making an Ajax request to one of your php files to handle the form data.
jQuery.post()
If this is a route you want to take, I'll write a small example
Related
I am a complete novice with PHP, I just want a simple email contact form that will display an error if a required field isn't entered, and will give a thank you message if the email is sent.
When I click my submit button the email does get sent but the website redirects straight to the /send-email.php page, which is blank and useless. The required form fields also don't seem to do anything in the way of preventing an email from being sent if the forms aren't filled.
HTML form code:
<form class="contact-form" action="php/send-email.php" method="post" novalidate>
<div class="row">
<div class="column width-6 pad-1 contact-column">
<h5>Your Name*</h5>
<input type="text" name="name" class="form-box" tabindex="1" required>
</div>
<div class="column width-6 pad-1 contact-column">
<h5>Email*</h5>
<input type="text" name="email" class="form-box" tabindex="2" required>
</div>
</div>
<div class="row mt-2">
<div class="column width-6 pad-1 contact-column">
<h5>Your Website</h5>
<input type="text" name="website" class="form-box" tabindex="3">
</div>
<div class="column width-6 pad-1 contact-column">
<h5>Company</h5>
<input type="text" name="company" class="form-box" tabindex="4">
</div>
</div>
<div class="column width-12">
<input type="text" name="honeypot" class="form-honeypot">
</div>
<div class="row mt-2">
<div class="column width-12 pad-1">
<h5>Your Message*</h5>
<textarea name="message" class="form-text" tabindex="5" required></textarea>
</div>
</div>
<div class="row mt-2">
<input type="submit" value="Send Your Message!" class="btn btn-large bg-blue">
</div>
</form>
Php file
<?php
$recipient = "contact#mysite.com";
$name = filter_var($_POST["name"], FILTER_SANITIZE_STRING);
$email = filter_var($_POST["email"], FILTER_SANITIZE_EMAIL);
$website = filter_var($_POST["website"], FILTER_SANITIZE_URL);
$company = filter_var($_POST["company"], FILTER_SANITIZE_STRING);
$message = filter_var($_POST["message"], FILTER_SANITIZE_STRING);
$headers = 'From: '.$name.' <'.$email.'>' . "\r\n";
$headers .= 'Reply-To: '.$email.'' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();
$subject = "New email from contact form";
$email_content = "Name: $name\n";
$email_content .= "Email: $email\n";
$email_content .= "Website: $website\n";
$email_content .= "Company: $company\n\n";
$email_content .= "Message:\n$message\n\n\n";
if(mail($recipient, $subject, $email_content, $headers)){
echo "Thanks for the email, we'll get back to as soon as possible!";
}
?>
Any help in the right direction is appreciated!
Check for empty input. Try using if else statement. eg.
if($name == '')
{
echo "Please fill in name";
}
else if($var == '')
{
//error message
}
or you can try
if($name == '' || $email == '' || $var == '')
{
echo "Please fill in all the blank";
}
I'm quite new too to PHP, so this is just a simple checking. Hope it'll helps!
I've made a contact form which works, but now I need it to be able to send an attachment too. I have found some examples but I cannot get them to work with my existing code. I'd prefer to keep as much of the form intact as the css is the way I'd like it.
I've omitted the the captcha and css in the code below.
<div class="contact-box" id="contact-form">
<div class="contact-form">
<form name="contact-form" action="">
<div class="name">
<span class="fa fa-user"></span>
<input id="name" placeholder="Name">
<label class="error" for="name" id="name_error"><i class="fa fa-exclamation-triangle"></i>Please enter your name.</label>
</div>
<div class="email">
<span class="fa fa-envelope"></span>
<input id="email" placeholder="Email">
<label class="error" for="email" id="email_error"><i class="fa fa-exclamation-triangle"></i>Please enter your email address.</label>
</div>
<div class="message">
<span class="fa fa-pencil"></span>
<textarea id="message" placeholder="Your Message"></textarea>
<label class="error" for="message" id="message_error"><i class="fa fa-exclamation-triangle"></i>Please enter your message</label>
</div>
<label class="attachment">
<input type="file" id="fileattachment"/>
<span>Upload Booking Request Form</span>
</label>
<div class="submit">
<input type="submit" name="submit" class="buttonsubmit" id="contact" value="Send">
</div>
</form>
</div>
</div>
<div class="contact-box">
<div class="contact-confirmation">
<i class="fa fa-paper-plane"></i>
<h3>Thanks for your message.</h3>
<h4>We'll be in touch soon!</h4></div>
</div>
<script>
$(function() {
//Hide send confirmation
$(".contact-confirmation").hide();
//Validate form
$('.error').hide();
$("input#contact").click(function() {
$('.error').hide();
var name = $("input#name").val();
if (name == "") {
$("label#name_error").show();
$("input#name").focus();
return false;
}
var email = $("input#email").val();
if (email == "") {
$("label#email_error").show();
$("input#email").focus();
return false;
}
var message = $("textarea#message").val();
if (message == "") {
$("label#message_error").show();
$("textarea#message").focus();
return false;
}
//Attachment part???
var attachment = $("#fileattachment")[0].files
//Send form
var dataString = 'name=' + name + '&email=' + email + '&message=' + message + '&attachment=' + attachment;
jQuery.ajax({
type: "POST",
url: "processemail.php",
data: dataString,
success: function() {
jQuery(".contact-confirmation").fadeIn(1000);
jQuery(".contact-form").hide();
}
});
return false;
});
});
</script>
//processemail.php
<?php
$name = $_POST["name"];
$email = $_POST["email"];
$message = $_POST["message"];
$sendto = $_POST["sendto"];
$sendto = 'overhere#example.com';
$headers = "From: " . $email . "\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body><strong>From: </strong>' . $name . '<br /><strong>Email: </strong>' . $email . '<br /><br /><strong>Message: </strong><br />' . $message . '</body></html>';
mail($sendto, $subject, $message, $headers);
?>
HTML with your form but some modifications. I use button submit and in the php, check POST and FILES variables. You need copy FILE to path. Find in google how copy file $_FILES to path.
<html>
<head>
<title></title>
<script src="http://code.jquery.com/jquery-2.2.0.min.js"></script>
</head>
<body>
<div class="contact-box" id="contact-form">
<div class="contact-form">
<form id="data" method="post" enctype="multipart/form-data">
<!--<form name="contact-form" action=""> -->
<div class="name">
<span class="fa fa-user"></span>
<input id="name" placeholder="Name" name="name">
<label class="error" for="name" id="name_error"><i class="fa fa-exclamation-triangle"></i>Please enter your name.</label>
</div>
<div class="email">
<span class="fa fa-envelope"></span>
<input id="email" placeholder="Email" name="email">
<label class="error" for="email" id="email_error"><i class="fa fa-exclamation-triangle"></i>Please enter your email address.</label>
</div>
<div class="message">
<span class="fa fa-pencil"></span>
<textarea id="message" placeholder="Your Message" name="message"></textarea>
<label class="error" for="message" id="message_error"><i class="fa fa-exclamation-triangle"></i>Please enter your message</label>
</div>
<label class="attachment">
<input type="file" id="fileattachment" name="file"/>
<span>Upload Booking Request Form</span>
</label>
<div class="submit">
<input type="submit" name="submit" class="buttonsubmit" id="contact" value="Send">
</div>
<button type="submit">Go</button>
</form>
</div>
</div>
<div class="contact-box">
<div class="contact-confirmation">
<i class="fa fa-paper-plane"></i>
<h3>Thanks for your message.</h3>
<h4>We'll be in touch soon!</h4></div>
</div>
<script>
$(function() {
//Hide send confirmation
$(".contact-confirmation").hide();
//Validate form
$('.error').hide();
/*
$("input#contact").click(function() {
$('.error').hide();
var name = $("input#name").val();
if (name == "") {
$("label#name_error").show();
$("input#name").focus();
return false;
}
var email = $("input#email").val();
if (email == "") {
$("label#email_error").show();
$("input#email").focus();
return false;
}
var message = $("textarea#message").val();
if (message == "") {
$("label#message_error").show();
$("textarea#message").focus();
return false;
}
//Attachment part???
var attachment = $("#fileattachment")[0].files
//Send form
var dataString = 'name=' + name + '&email=' + email + '&message=' + message + '&attachment=' + attachment;
});
*/
$("form#data").submit(function(){
console.log($(this));
var formData = new FormData($(this)[0]);
$.ajax({
url : 'processemail.php',
type: 'POST',
data: formData,
async: false,
success: function (data) {
alert(data)
},
cache: false,
contentType: false,
processData: false
});
return false;
});
});
</script>
</body>
</html>
And in the php
<?php
//var_dump($_POST);
//var_dump($_FILES);
$uploads_dir = ""; /* local path */
if(isset($_FILES['file']) && ($_FILES['file']['error'] == 0) ) {
$tmp_name = $_FILES["file"]["tmp_name"];
$name = $_FILES["file"]["name"];
move_uploaded_file($tmp_name, "{$uploads_dir}{$name}");
}
$name = $_POST["name"];
$email = $_POST["email"];
$message = $_POST["message"];
//$sendto = $_POST["sendto"];
$sendto = 'overhere#example.com';
$headers = "From: " . $email . "\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body><strong>From: </strong>' . $name . '<br /><strong>Email: </strong>' . $email . '<br /><br /><strong>Message: </strong><br />' . $message . '</body></html>';
mail($sendto, $subject, $message, $headers);
?>
You need to submit the form using the formData object.
$("form").submit(function(){
var formData = new FormData($(this)[0]);
$.ajax({
url: window.location.pathname,
type: 'POST',
data: formData,
async: false,
success: function (data) {
alert(data)
},
cache: false,
contentType: false,
processData: false
});
return false;
});
This should do the job.
I have a JSON code in a sendemail.php file for my Bootstrap 3 contact form. The form is able to send an email to the specified email address but there is no data being submitted. I get blank emails with labels and the header 'unknown sender'. Please help solve this.
This is the bootsrap form code chunk
<div class="col-sm-6">
<h1>Contact Form</h1>
<p>Please contact us using the form or our contact details are available here if you'd like to contact us via Email or Phone.</p>
<div class="status alert alert-success" style="display: none"></div>
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php" role="form">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="Name" class="form-control" required placeholder="Name">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="Email" class="form-control" required placeholder="Email address">
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<textarea name="Message" id="message" required class="form-control" rows="8" placeholder="Message"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-danger btn-lg">Send Message</button>
</div>
</div>
</div>
</form>
</div><!--/.col-sm-6-->
This is the main.js code where the AJAX for contact form is present
jQuery(function($) {
$(function(){
$('#main-slider.carousel').carousel({
interval: 5000,
pause: false
});
});
//Ajax contact
var form = $('.contact-form');
form.submit(function () {
$this = $(this);
$.post($(this).attr('action'), function(data) {
$this.prev().text(data.message).fadeIn().delay(3000).fadeOut();
},'json');
return false;
});
//smooth scroll
$('.navbar-nav > li').click(function(event) {
if(!$( this ).attr( 'href' ).match(/^#/)) return;
event.preventDefault();
var target = $(this).find('>a').prop('hash');
$('html, body').animate({
scrollTop: $(target).offset().top
}, 500);
});
//scrollspy
$('[data-spy="scroll"]').each(function () {
var $spy = $(this).scrollspy('refresh')
})
//PrettyPhoto
$("a.preview").prettyPhoto({
social_tools: false
});
//Isotope
$(window).load(function(){
$portfolio = $('.portfolio-items');
$portfolio.isotope({
itemSelector : 'li',
layoutMode : 'fitRows'
});
$portfolio_selectors = $('.portfolio-filter >li>a');
$portfolio_selectors.on('click', function(){
$portfolio_selectors.removeClass('active');
$(this).addClass('active');
var selector = $(this).attr('data-filter');
$portfolio.isotope({ filter: selector });
return false;
});
});
});
This is the sendemail.php code
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Email sent!'
);
$name = $_POST['Name'];
$email = $_POST['Email'];
$subject = $_POST['Subject'];
$message = $_POST['Message'];
$email_from = $email;
$email_to = 'myemail#domain.com';
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;
$success = #mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die;
?>
You are missing the name attribute in your html input tags
This is required for the server side variables, for example:
$name = $_POST['Name'];
will get value from
<input type="text" name="Name" class="form-control" required placeholder="Name">
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php" role="form">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<input name="Name" type="text" class="form-control" required placeholder="Name">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input name="Email" type="text" class="form-control" required placeholder="Email address">
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<textarea name="Message" id="message" required class="form-control" rows="8" placeholder="Message"></textarea>
</div>
<div class="form-group">
<input type="submit" class="btn btn-danger btn-lg" value="Send Message">
</div>
</div>
</div>
</form>
<?php
if(isset($_POST['submit'],$_POST['Name'],$_POST['Email'],$_POST['Subject'],$_POST['Message'])){
$name = $_POST['Name'];
$email = $_POST['Email'];
$subject = $_POST['Subject'];
$message = $_POST['Message'];
$email_from = $email;
$email_to = 'myemail#domain.com';
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;
$success = mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
$response = array();
if($success){
$response['success'] = true;
$response['message'] = 'Email sent!';
}else{
$response['success'] = false;
$response['message'] = 'Email sent!';
}
}else{
$response['success'] = false;
$response['message'] = 'post variables are not set';
}
echo json_encode($response);
//die;
Change this line in main.js:
$.post($(this).attr('action'), function(data) {
to:
$.post($(this).attr('action'), $(this).serialize(), function(data) {
It will now submit the data.
I've looked at various solutions but I just can't get my contact form to work. **The issue im having is that the email wont actually send out to me, everything works client side but I dont get the email. So I have come here to surely get the duplicate question label. Here is my code:
<form method="post" class="reply" id="contact" action="process.php">
<fieldset>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<label>Name: <span>*</span></label>
<input class="form-control" id="name" name="name" type="text" value="" required>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<label>Email: <span>*</span></label>
<input class="form-control" type="email" id="email" name="email" value="" required>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<label>Subject: <span>*</span></label>
<input class="form-control" id="subject" name="subject" type="text" value="" required>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<label>Message: <span>*</span></label>
<textarea class="form-control" id="text" name="text" rows="3" cols="40" required></textarea>
</div>
</div>
</fieldset>
<button class="btn btn-normal btn-color submit bottom-pad" type="submit">Send</button>
<div class="success alert-success alert" style="display:none">Your message has been sent successfully.</div>
<div class="error alert-error alert" style="display:none">E-mail must be valid and message must be longer than 100 characters.</div>
<div class="clearfix">
</div>
</form>
Here is my process.php
<?php
// Email Submit
// Note: filter_var() requires PHP >= 5.2.0
if ( isset($_POST['email']) && isset($_POST['name']) && isset($_POST['subject']) && isset($_POST['text']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {
// detect & prevent header injections
$test = "/(content-type|bcc:|cc:|to:)/i";
foreach ( $_POST as $key => $val ) {
if ( preg_match( $test, $val ) ) {
exit;
}
}
// PREPARE THE BODY OF THE MESSAGE
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['name']) . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['email']) . "</td></tr>";
$message .= "<tr><td><strong>Message:</strong> </td><td>" . htmlentities($_POST['text']) . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
// CHANGE THE BELOW VARIABLES TO YOUR NEEDS
$to = 'iknowichange#this.com';
$subject = $_POST['subject'];
$headers = "From: " . $_POST['email'] . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $message, $headers);
}
?>
I am completely new to forms, so thanks in advance for the help. If there are any resources that you can suggest that would be great. Thanks!
It looks like you just forgot to include an action in your form element.
(Unless your binding an onsubmit event somewhere else)
Try
<form method="post" class="reply" id="contact" action="process.php">
You haven't set any action in your form element. You've to set the path of your "process.php" in form element like following:
<form action="process.php" method="post" id="contact" class="reply">
...
</form>
More about form: http://www.w3schools.com/html/html_forms.asp
This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 9 years ago.
So I'm coding a contact form for a website, but I want to be able to allow the user to enter non-latin based characters (i.e. é or 車) but I can't exactly figure out where I would set that up - once the user submits the form, it passes it through an AJAX section in jQuery which then processes that to PHP (which prevents the page from refreshing) but trying to use utf8_encode() didn't work and setting the contentType for the data in .ajax() didn't help either, so now I'm not sure what to do.
Anyone able to help me out?
HTML form
<form action="" id="contactUs" method="post">
<div class="input-group">
<span class="input-group-addon">name</span>
<input type="text" class="form-control" placeholder="Your Name/Company" tabindex="1" name= "name" id="name" />
</div>
<div class="input-group">
<span class="input-group-addon" style="padding-right: 18px;">mail</span>
<input type="email" class="form-control" placeholder="Your/Your Company Email" tabindex="2" name="email" id="email" />
</div>
<div class="input-group">
<span class="input-group-addon" style="padding-right: 18px;">subject</span>
<input type="text" class="form-control" placeholder="The subject of your message" tabindex="2" name="subject" id="subject" />
</div>
<div class="input-group">
<span class="input-group-addon" style="padding-right: 18px;">message</span>
<textarea class="form-control" placeholder="What's on your mind?" cols="100" rows="4" tabindex="3" name="msg" id="msg"></textarea>
</div>
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default" type="submit" style="-webkit-border-radius: 8px; border-radius: 8px; position: relative; left: 41%;" id="submit">Submit</button>
</span>
</div>
</form>
jQuery
var dataString = 'name=' + name + '&email=' + email + "&subject=" + subject + '&msg=' + msg;
$.ajax ({
type: "POST",
url: "process.php",
data: {
name : name,
email : email,
subject :subject,
msg : msg
},
contentType: "application/x-www-form-urlencoded;charset=ISO-8859-15",
dataType: 'json',
complete: function() {
$("#error").hide();
$("#errormail").hide();
$("textarea#msg").css("background-color", "#ffffff");
$("input#email").css("background-color", "#ffffff");
$("input#name").css("background-color", "#ffffff");
$("#success").show();
setTimeout(
function(){ $('#success').fadeOut() }, 5000
);
$( '#contactUs' ).each(function(){
this.reset();
});
}
});
PHP
<?php
if(isset($_POST['email'])) {
$email_to = "info#infinitedream.net ";
$email_from = $_POST['email']; // required
$email_subject = $_POST['subject'];
$name = $_POST['name']; // required
$message = $_POST['msg']; // required
$email_message = '<html><body>';
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= '<table rules="all" style="border: 1px solid #666;" cellpadding="10">';
$email_message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . strip_tags($name) . "</td></tr>";
$email_message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($email_from) . "</td></tr>";
$email_message .= "<tr><td><strong>Message:</strong> </td><td>" . utf8_encode($message) . "</td></tr>";
$email_message .= "</table>";
$email_message .= "</body></html>";
// create email headers
$headers = 'From: '.$email_from."\r\n";
$headers = 'Reply-To: '.$email_from."\r\n";
$headers = 'X-Mailer: PHP/' . phpversion();
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers = "Content-type:text/html;charset=iso-8859-1" . "\r\n";
mail($email_to, $email_subject, $email_message, $headers);
}
?>
Do you have the charset meta?
<meta charset="utf-8">
Also try changing the document's encoding to UTF-8.