Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Funkcja ()mail - kodowanie.
Lookdem
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 24.01.2012

Ostrzeżenie: (0%)
-----


Witam, skorzystałem z jednego skryptu do wysyłania formularza kontaktowego na maila. Jednak po wysłaniu, nie widać polskich znaków. Czytałem, że powinienem dodać kodowanie :
  1. "Content-Type: text/plain; charset=UTF-8\r\n"

Kombinowałem z tym, jednak dopiero zaczynam z PHP i nie wiem w jakich miejscach trzeba to ustawić. Proszę o pomoc i krótkie uzasadnienie czemu właśnie tak.

Mój kod :
  1. <?
  2.  
  3. $mailto = "moj@mail";
  4. $cc = "";
  5. $bcc = "";
  6. $subject = "Temat";
  7. $vname = "Formularz kontaktowy";
  8.  
  9.  
  10. $email = $_POST['email'];
  11.  
  12. function validateEmail($email)
  13. {
  14. if(eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}(\.[a-zA-Z]{2,3})?(\.[a-zA-Z]{2,3})?$', $email))
  15. return true;
  16. else
  17. return false;
  18. }
  19.  
  20.  
  21. if(strlen($_POST['name']) < 1 || strlen($_POST['message']) < 1 || validateEmail($email) == FALSE)
  22. {
  23. $emailerror = 'Błędy:';
  24.  
  25. if(empty($_POST['name']))
  26. {
  27. $emailerror .= '<li>Podaj imię i nazwisko.</li>';
  28. }
  29.  
  30. if(validateEmail($email) == FALSE)
  31. {
  32. $emailerror .= '<li>Podaj prawidłowy adres email</li>';
  33. }
  34.  
  35. if(empty($_POST['message']))
  36. {
  37. $emailerror .= '<li>Wpisz treść wiadomości.</li>';
  38. }
  39. }
  40. else
  41. {
  42. $emailerror .= "Twoja wiadomość została wysłana.";
  43.  
  44. // NOW SEND THE ENQUIRY
  45. $timestamp = date("F j, Y, g:ia");
  46.  
  47. $messageproper ="\n\n" .
  48. "Name: " .
  49. ucwords($_POST['name']) .
  50. "\n" .
  51. "Email: " .
  52. ucwords($email) .
  53. "\n" .
  54. "Comments: " .
  55. $_POST['message'] .
  56. "\n" .
  57. "\n\n" ;
  58.  
  59. $messageproper = trim(stripslashes($messageproper));
  60. mail($mailto, $subject, $messageproper, "From: \"$vname\" <".$_POST['e_mail'].">\nReply-To: \"".ucwords($_POST['first_name'])."\" <".$_POST['e_mail'].">\nX-Mailer: PHP/" . phpversion() );
  61. }
  62. ?>
  63.  
  64. <div id='emailerror'>
  65. <ul>
  66. <? echo $emailerror; ?>
  67. </ul>
  68. </div>


Z góry dziękuję i pozdrawiam (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Lookdem
post
Post #2





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 24.01.2012

Ostrzeżenie: (0%)
-----


Proszę, oryginalny przed zmianami :
  1. <?
  2.  
  3. $mailto = "moj@mail";
  4. $cc = "";
  5. $bcc = "";
  6. $subject = "Temat";
  7. $vname = "Formularz kontaktowy";
  8.  
  9.  
  10.  
  11.  
  12. $email = $_POST['email'];
  13.  
  14.  
  15. function validateEmail($email)
  16.  
  17. {
  18.  
  19. if(eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}(\.[a-zA-Z]{2,3})?(\.[a-zA-Z]{2,3})?$', $email))
  20.  
  21. return true;
  22.  
  23. else
  24.  
  25. return false;
  26.  
  27. }
  28.  
  29.  
  30.  
  31.  
  32.  
  33. if(strlen($_POST['name']) < 1 || strlen($_POST['message']) < 1 || validateEmail($email) == FALSE)
  34.  
  35. {
  36.  
  37. $emailerror = 'Błędy:';
  38.  
  39.  
  40.  
  41. if(empty($_POST['name']))
  42.  
  43. {
  44.  
  45. $emailerror .= '<li>Podaj imię i nazwisko.</li>';
  46.  
  47. }
  48.  
  49.  
  50.  
  51. if(validateEmail($email) == FALSE)
  52.  
  53. {
  54.  
  55. $emailerror .= '<li>Podaj prawidłowy adres email</li>';
  56.  
  57. }
  58.  
  59.  
  60.  
  61. if(empty($_POST['message']))
  62.  
  63. {
  64.  
  65. $emailerror .= '<li>Wpisz treść wiadomości.</li>';
  66.  
  67. }
  68.  
  69. }
  70.  
  71. else
  72.  
  73. {
  74.  
  75. $emailerror .= "Twoja wiadomość została wysłana.";
  76.  
  77.  
  78.  
  79. // NOW SEND THE ENQUIRY
  80.  
  81. $timestamp = date("F j, Y, g:ia");
  82.  
  83.  
  84.  
  85. $messageproper ="\n\n" .
  86.  
  87. "Name: " .
  88.  
  89. ucwords($_POST['name']) .
  90.  
  91. "\n" .
  92.  
  93. "Email: " .
  94.  
  95. ucwords($email) .
  96.  
  97. "\n" .
  98.  
  99. "Comments: " .
  100.  
  101. $_POST['message'] .
  102.  
  103. "\n" .
  104.  
  105. "\n\n" ;
  106.  
  107.  
  108.  
  109. $messageproper = trim(stripslashes($messageproper));
  110.  
  111. mail($mailto, $subject, $messageproper, "From: \"$vname\" <".$_POST['e_mail'].">\nReply-To: \"".ucwords($_POST['first_name'])."\" <".$_POST['e_mail'].">\nX-Mailer: PHP/" . phpversion() );
  112.  
  113. }
  114.  
  115. ?>
  116.  
  117.  
  118.  
  119. <div id='emailerror'>
  120.  
  121. <ul>
  122.  
  123. <? echo $emailerror; ?>
  124.  
  125. </ul>
  126.  
  127. </div>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 8.10.2025 - 01:44