Witam!

Mam następujący problem: po wysłaniu za pomocą funkcji mail() emaila, którego treść pochodzi z formularza kontaktowego, dostaję na skrzynkę treść, bez polskich znaków. Wiem, że problem tkwi gdzieś w kodowaniu.

oto skrypt:

  1. <?php
  2.  
  3. ?>
  4. <html>
  5. <head>
  6. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
  7. <meta http-equiv="content-language" content="pl" />
  8. </head>
  9.  
  10.  
  11.  
  12. <?php
  13. $imie=$_POST['imie'];
  14. $email=$_POST['email'];
  15. $tresc=$_POST['tresc'];
  16. $ID=$_POST['ID'];
  17.  
  18.  
  19. if (($imie=="")||($email=="")||($tresc=="")||($ID==""))
  20. {
  21. header('Location: index.php?info=Nie wypełniono wszystkich pól');
  22. }
  23.  
  24. else{
  25.  
  26. $sprawdz=$_SESSION['captcha'];
  27. $kod = $_POST['ID'];
  28. $kod=strtolower($kod);
  29. if ($kod==$sprawdz)
  30. {
  31.  
  32. $poprawny_email=filter_var($email, FILTER_VALIDATE_EMAIL);
  33.  
  34. if ($poprawny_email!="")
  35. {
  36.  
  37. $to = "wujekkk@vp.pl";
  38. $subject = "Zapytanie wysłane ze strony biblioteki";
  39. $message = "Pan/Pani ".$imie." Napisał/Napisała: \n \n".$tresc;
  40.  
  41. $headers = "MIME-Version: 1.0";
  42. $headers .= "Content-type: text/html; charset=iso-8859-2";
  43. $headers = "From: " . $email . "\n" . "Return-Path: " . $email . "\n" . "Reply-To: " . $email . "\n";
  44. $submit = mail($to, $subject, $message, $headers);
  45. if ($submit)
  46. header('Location: index.php?info=Wiadomość została wysłana');
  47. else
  48. header('Location: index.php?info=Wiadomości nie wysłano. Proszę ponowić próbę');
  49. }
  50. else
  51. {
  52. header('Location: index.php?info=Nieprawidłowy adres email');
  53. }
  54. }
  55. else
  56. {
  57. header('Location: index.php?info=Wpisano niepoprawny kod');
  58. }
  59. }
  60. ?>
  61.  
  62. </html>



a oto formularz:

  1. <FORM action="raz.php" Method="POST" accept-charset="iso-8859-2" onSubmit="return sprawdz(this);">
  2. Twoje imię: <INPUT NAME="imie"><br>
  3. Twój email: <INPUT NAME="email"><br>
  4. Treść:<textarea rows="4" cols="17" NAME="tresc">
  5. <img src="obraz.php">
  6. Kod z obrazka: <INPUT NAME="ID" size=5><br>
  7. <INPUT TYPE="submit" VALUE="Wyślij">
  8. </form>
  9. <br>


Dodam, że wyświetlając 'echem' $tresc w skrypcie wszystko jest ok, tzn są polskie znaki.

Pomożecie??

Problem rozwiązałem sam. Temat do zamknięcia!

  1. <?php
  2.  
  3. ?>
  4. <html>
  5. <head>
  6. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
  7. <meta http-equiv="content-language" content="pl" />
  8. </head>
  9.  
  10.  
  11.  
  12. <?php
  13. $imie=$_POST['imie'];
  14. $email=$_POST['email'];
  15. $tresc=$_POST['tresc'];
  16. $ID=$_POST['ID'];
  17.  
  18. if (($imie=="")||($email=="")||($tresc=="")||($ID==""))
  19. {
  20. header('Location: index.php?info=Nie wypełniono wszystkich pól');
  21. }
  22.  
  23. else{
  24.  
  25. $sprawdz=$_SESSION['captcha'];
  26. $kod = $_POST['ID'];
  27. $kod=strtolower($kod);
  28. if ($kod==$sprawdz)
  29. {
  30.  
  31. $poprawny_email=filter_var($email, FILTER_VALIDATE_EMAIL);
  32.  
  33. if ($poprawny_email!="")
  34. {
  35.  
  36. $to = "wujekkk@vp.pl";
  37. $subject = "Zapytanie wysłane ze strony biblioteki";
  38. $message = "Pan/Pani ".$imie." Napisał/Napisała: \r\n \r\n".$tresc;
  39. $message=nl2br($message);
  40.  
  41. $subject="=?iso-8859-2?B?".base64_encode($subject)."?=";
  42. $tresc="=?iso-8859-2?B?".base64_encode($tresc)."?=";
  43.  
  44. $headers = "MIME-Version: 1.0\n";
  45. $headers .= "Content-type: text/html; charset=ISO-8859-2\n";
  46. $headers .= "Content-Transfer-Encoding: 8bit\n";
  47. $headers.= "From: " . $email . "\n" . "Return-Path: " . $email . "\n" . "Reply-To: " . $email . "\n";
  48.  
  49. $submit = mail($to, $subject, $message, $headers);
  50. if ($submit)
  51. header('Location: index.php?info=Wiadomość została wysłana');
  52. else
  53. header('Location: index.php?info=Wiadomości nie wysłano. Proszę ponowić próbę');
  54. }
  55. else
  56. {
  57. header('Location: index.php?info=Nieprawidłowy adres email');
  58. }
  59. }
  60. else
  61. {
  62. header('Location: index.php?info=Wpisano niepoprawny kod');
  63. }
  64. }
  65. ?>
  66.  
  67. </html>