Jump to content

utf8 in my contac form not working...


jonybigude

Recommended Posts

Hi!

I have been searching on the web for solutions but for some reason it seems that I can't implement them. I am a rookie in PHP and perhaps the mistake has been under my nose all this time but I did not manage to see it...

Here goes my contact form:
 

<form method="post" action="kontakt.php">

<label>Namn *</label>
<input name="name" placeholder="Type Here">

<label>Telefon *</label>
<input name="telef" placeholder="Type Here">

<label>E-post *</label>
<input name="email" type="email" placeholder="Type Here">

<label>Meddelandet</label>
<textarea name="message" placeholder="Type Here"></textarea>

<label>*Hur mycket är 2+2? (Anti-spam)</label>
<input name="human" placeholder="Type Here">

<input id="submit" name="submit" type="submit" value="Submit">


<?php
$name = $_POST['name'];
$telef = $_POST['telef'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'Lounge Terrasse';
$to = 'kontakt@lfsolutions.se';
$subject = 'Lounge Terrasse - Ny meddelande';
$human = $_POST['human'];

$headers = "MIME-Version: 1.0" . PHP_EOL;
$headers .= "From: $from <$email> ". PHP_EOL;
$headers .= "Content-type: text/html;charset=UTF-8 ". PHP_EOL;


$body = "From: $name\n Telefon: $telef\n E-Mail: $email\n Message:\n $message";

if ($_POST['submit']) {
if ($name != '' && $email != '' && $telef != '') {
if ($human == '4') {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
} else if ($_POST['submit'] && $human != '4') {
echo '<p>You answered the anti-spam question incorrectly!</p>';
}
} else {
echo '<p>You need to fill in all required fields!!</p>';
}
}
?>

</form>


So... any suggestions in order to implement correctly the utf8, since the e-mails are still coming with weird characters?

Thanks in advance!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.