Oto kawałek kodu:
<?php
require_once('form_config.php');
// Check to see if the form has been submitted
if (isset($_POST['submit'])) {
require_once('recaptchalib.php');
$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
// Assign the post variable and sanitize it
$name = (filter_var($_POST['name'], FILTER_SANITIZE_STRING));
if ($name == "") $errors .= 'Wpisz imię i nazwisko.<br />';
// Sanitize the email address and check it is valid
$email = (filter_var($_POST['email'], FILTER_SANITIZE_EMAIL));
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) $errors .= "Wpisz poprawny adres email.<br />";
// Sanitize the phone number if it exists
if ($_POST['phone'] != "") {
$phone = (filter_var($_POST['phone'], FILTER_SANITIZE_STRING));
}
// Sanitize the theme
$tematyka = (filter_var($_POST['tematyka'], FILTER_SANITIZE_STRING));
if ($tematyka == "") $errors .= 'Wybierz interesujący Cię temat pracy.<br />';
// Sanitize the company if it exists
if ($_POST['company'] != "") {
$company = (filter_var($_POST['company'], FILTER_SANITIZE_STRING));
}
// Sanitize the URL if it exists
if ($_POST['website'] != "") {
$website = (filter_var($_POST['website'], FILTER_SANITIZE_URL));
if (!filter_var($website, FILTER_VALIDATE_URL)) $errors .= "Adres strony www nie jest poprawnie napisany. Sprawdź przykład poniżej.<br />";
}
// Sanitize the comments
$comments = (filter_var($_POST['comments'], FILTER_SANITIZE_STRING));
if ($comments == "") $errors .= 'Wpisz treść.<br />';
// Check to see if any errors did occur
$validation_check="";
if(isset($errors)) $validation_check.= $errors; if (!$resp->is_valid) $validation_check.="Pole reCAPTCHA nie zostało poprawnie wypełnione.<br />";
// If no errors then send the mail and create the success message
if (!$validation_check) {
$message = "Imie i nazwisko: ".$name."\r\n"."Telefon: ".$phone."\r\n"."Tematyka: ".$tematyka."\r\n"."Wiadomosc: ".$comments."\r\n";
mail($my_email, "Formularz kontaktowy z $my_website", $message, "From: $email"); $validation_message = $success_message;
} else {
$validation_message = $validation_check;}
}
?>
w mail próbowałem wstawić (wkleiłem to nad "mail" a po "from" dodałem ", $headers'):
$header = "MIME-Version: 1.0\r\n";
$header .="Content-type: text/html; charset=UTF-8\r\n";
$header .= "Content-Transfer-Encoding: 8bit\n";
$header .="From: <".$from.">\r\n";
ale nadal są krzaki. Strona jest w utf-8. Co tu jest nie tak?