Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]php mail nie ma polskich znaków
Forum PHP.pl > Forum > Przedszkole
fizyczny
Oto kawałek kodu:

  1. <?php
  2.  
  3. require_once('form_config.php');
  4. // Check to see if the form has been submitted
  5. if (isset($_POST['submit'])) {
  6.  
  7. require_once('recaptchalib.php');
  8. $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
  9.  
  10. // Assign the post variable and sanitize it
  11.  
  12.  
  13. $name = (filter_var($_POST['name'], FILTER_SANITIZE_STRING));
  14. if ($name == "") $errors .= 'Wpisz imię i nazwisko.<br />';
  15.  
  16. // Sanitize the email address and check it is valid
  17. $email = (filter_var($_POST['email'], FILTER_SANITIZE_EMAIL));
  18. if (!filter_var($email, FILTER_VALIDATE_EMAIL)) $errors .= "Wpisz poprawny adres email.<br />";
  19.  
  20. // Sanitize the phone number if it exists
  21. if ($_POST['phone'] != "") {
  22. $phone = (filter_var($_POST['phone'], FILTER_SANITIZE_STRING));
  23. }
  24.  
  25. // Sanitize the theme
  26. $tematyka = (filter_var($_POST['tematyka'], FILTER_SANITIZE_STRING));
  27. if ($tematyka == "") $errors .= 'Wybierz interesujący Cię temat pracy.<br />';
  28.  
  29.  
  30. // Sanitize the company if it exists
  31. if ($_POST['company'] != "") {
  32. $company = (filter_var($_POST['company'], FILTER_SANITIZE_STRING));
  33. }
  34.  
  35. // Sanitize the URL if it exists
  36. if ($_POST['website'] != "") {
  37. $website = (filter_var($_POST['website'], FILTER_SANITIZE_URL));
  38. if (!filter_var($website, FILTER_VALIDATE_URL)) $errors .= "Adres strony www nie jest poprawnie napisany. Sprawdź przykład poniżej.<br />";
  39. }
  40.  
  41. // Sanitize the comments
  42. $comments = (filter_var($_POST['comments'], FILTER_SANITIZE_STRING));
  43. if ($comments == "") $errors .= 'Wpisz treść.<br />';
  44.  
  45. // Check to see if any errors did occur
  46. $validation_check="";
  47. if(isset($errors)) $validation_check.= $errors;
  48. if (!$resp->is_valid) $validation_check.="Pole reCAPTCHA nie zostało poprawnie wypełnione.<br />";
  49.  
  50.  
  51. // If no errors then send the mail and create the success message
  52. if (!$validation_check) {
  53. $message = "Imie i nazwisko: ".$name."\r\n"."Telefon: ".$phone."\r\n"."Tematyka: ".$tematyka."\r\n"."Wiadomosc: ".$comments."\r\n";
  54.  
  55.  
  56.  
  57. mail($my_email, "Formularz kontaktowy z $my_website", $message, "From: $email");
  58. $validation_message = $success_message;
  59. } else {
  60. $validation_message = $validation_check;}
  61. }
  62. ?>



w mail próbowałem wstawić (wkleiłem to nad "mail" a po "from" dodałem ", $headers'):

  1. $header = "MIME-Version: 1.0\r\n";
  2. $header .="Content-type: text/html; charset=UTF-8\r\n";
  3. $header .= "Content-Transfer-Encoding: 8bit\n";
  4. $header .="From: <".$from.">\r\n";


ale nadal są krzaki. Strona jest w utf-8. Co tu jest nie tak?
sajegib
A kodowanie w edytorze jak masz ustawione?
fizyczny
odczytywanie/zapisywanie utf-8

To jest ten skrypt:
Link do skryptu
-chryssalid-
Przyczyn może być wiele:
- dajesz text/html, wstawiasz suchy tekst - klient nie ma info o kodowaniu i może źle wybierać domyślne
- utf-8 w nagłówku musi być w cudzysłowie
- na wszelki wypadek Content-Type camelcasem - maile są bardzo wrażliwe na nagłówki
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.