Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [HTML][PHP]Polskie znaki w formularzu
Forum PHP.pl > Forum > Przedszkole
rossco
Witam,

w mailu z formularza kontaktowego nie wyświetlają się polskie znaki. Proszę o podpowiedź gdzie jest błąd.

index.html

  1. <form method="POST" name="contactform" action="contact-form-handler.php">
  2. <div class="row 50%">
  3. <div class="6u 12u(mobile)"><input type="text" name="name" placeholder="Imie" /></div>
  4. <div class="6u 12u(mobile)"><input type="email" name="email" placeholder="Email" /></div>
  5. </div>
  6. <div class="row 50%">
  7. <div class="12u"><textarea name="message" placeholder="Tresc wiadomosci" rows="6"></textarea></div>
  8. </div>
  9. <div class="row">
  10. <div class="12u">
  11. <ul class="actions">
  12. <li><input type="submit" value="Wyślij" /></li>
  13. </ul>
  14. </div>
  15. </div>
  16. </form>



contact-form-handler.php

  1. <?php
  2. $errors = '';
  3. $myemail = 'kontakt@mail.pl';//<-----Put Your email address here.
  4. if(empty($_POST['name']) ||
  5. empty($_POST['email']) ||
  6. empty($_POST['message']))
  7. {
  8. $errors .= "\n Błąd: wszystkie pola są wymagane";
  9. }
  10.  
  11. $name = $_POST['name'];
  12. $email_address = $_POST['email'];
  13. $message = $_POST['message'];
  14.  
  15. "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
  16. $email_address))
  17. {
  18. $errors .= "\n Error: Invalid email address";
  19. }
  20.  
  21. if( empty($errors))
  22. {
  23. $to = $myemail;
  24. $email_subject = "Contact form submission: $name";
  25. $email_body = "You have received a new message. ".
  26. " Here are the details:\n Name: $name \n Email: $email_address \n Message \n $message";
  27.  
  28. $headers = "From: $myemail\n";
  29. $headers .= "Reply-To: $email_address";
  30.  
  31. mail($to,$email_subject,$email_body,$headers);
  32. //redirect to the 'thank you' page
  33. header('Location: contact-form-thank-you.html');
  34. }
  35. ?>
  36. <!DOCTYPE HTML>
  37. <html lang="pl">
  38. <html>
  39. <head>
  40. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  41. <title>Contact form handler</title>
  42. </head>
  43.  
  44. <body>
  45. <!-- This page is displayed only if there is some error -->
  46. <?php
  47. echo nl2br($errors);
  48. ?>
  49.  
  50.  
  51. </body>
  52. </html>


contact-form-thank-you.html

  1.  
  2. <!DOCTYPE HTML>
  3. <html lang="pl">
  4. <meta charset="utf-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  6.  
  7. <title>Dziękujemy za przesłanie formularza</title>
  8. <!-- define some style elements-->
  9. h1
  10. {
  11. font-family : Arial, Helvetica, sans-serif;
  12. font-size : 16px;
  13. font-weight : bold;
  14. }
  15. label,a,body
  16. {
  17. font-family : Arial, Helvetica, sans-serif;
  18. font-size : 12px;
  19. }
  20.  
  21. </style>
  22. <!-- a helper script for vaidating the form-->
  23. </head>
  24. </head>
  25.  
  26. <h1>Dziękujemy za przesłanie formularza.</h1>
  27. Skontaktuje się z Państwem wkrótce!
  28.  
  29.  
  30. </body>
  31. </html>
  32.  

prz3kus
Do nagłówka email dodaj:
  1. "Content-type: text/html; charset=UTF-8" . "\r\n";


Jeszcze uwaga style szablonu wysyłanego emailu pisane w podany sposób nie zadziałają poprawnie na wszytkich poczatch.
rossco
gdzie konkretnie i w jakim pliku?

w którym wierszu?
viking
A gdzie masz $headers? 29 linia.
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.