Hello guyz and thank you in advance. I have made an email form using php to send an email through a form from my website
Although the form works fine and the emails are sent I have a problem when I sent a message in my native language (Greek). If I write the message in English everything is fine and the email is view-able. If I send a message in Greek then the email is sent , but looks like this :
³Î¾ÏƒÎ»Î´Î³Î·ÎºÎ»ÏƒÎ´ ασλαηκσλκαςξδςακσ³Î¾ÏƒÎ»Î´Î³Î·ÎºÎ»ÏƒÎ´ ασλαηκσλκαςξδςακσ
Here is the code I use in my php form :
<?php
if(isset($_POST['email'])) {
$email_to = "info@something.gr";
$email_subject = "Email Form - WebSite";
function died($error) {
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
$first_name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$comments = $_POST['message']; // required
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Message: ".clean_string($comments)."\n";
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
<center>
Thank you for contacting us. We will be in touch with you very soon.</br>
You will be redirected to our homepage in 5 seconds </center>
<script type="text/javascript">
setTimeout("window.location='/'",5000);
</script>
<?php
}
?>