1

I'm building a contact form with PHP that sends the content via mail. I just have a couple of questions that I don't find a solution for on my own.

The first must be simple, but I can't get it why I don't get any line breaks in this code:

$contactForm = $form_name . "\n";
$contactForm .= $form_email . "\n";
$contactForm .= $form_message . "\n";

And my second question is how I can have swedish letters like åäö instead of these strange letters: öäå

I'm using PHPMailer and I have set it to swedish with this line of code,

$mail->setLanguage('se', '/optional/path/to/language/directory/');

EDIT!! I missed to change the path for the language folder in the line above! Have fixed that now!

$mail->setLanguage('se', '/language/');

but it seems like this isn't the problem. I guess it must be some problem with UTF-8 or is it the PHP-code that sanitize the variables?

I'm using this to sanitize the input values:

// Security - call function
$form_name = check_input($_POST['name']);
$form_email = check_input($_POST['email']);
$form_message = check_input($_POST['message']);

// Function to check input
function check_input($data){

$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
$data = strip_tags($data);
return $data;
}

Preciate some help!

3D-kreativ
  • 9,053
  • 37
  • 102
  • 159

0 Answers0