Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [HTML][PHP]Formularz kontaktowy i krzaczki w wiadomości
Forum PHP.pl > Forum > Przedszkole
Szunaj85
Ostatnio w internecie znalazłem taki formularz.
Wiem, że w tej formie nie jest to jakieś cudo, ale do mniejszego projektu wystarczy.
Swoją drogą zamierzam go trochę przerobić i poprawić.
I teraz sedno. W wiadomościach przesłanych za pomocą tego formularza są krzaczki.
Prawdobodobnie brakuje jakiś nagłówków, które też już próbowałem dopisywać, jednak bez skutku.
  1. <?PHP
  2. error_reporting(E_ALL ^ E_NOTICE);
  3. $email = 'adres@gmail.com'; // adres na ktory beda wysylane wiadomosci
  4.  
  5.  
  6. ' <!DOCTYPE html>
  7. <html>
  8.  
  9. <head>
  10. <title>Formularz kontaktowy</title>
  11. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  12. <link rel="stylesheet" href="form_style_01.css" type="text/css" media="all" />
  13. </head>
  14. <body>
  15. ';
  16.  
  17. if($_POST['form_ok'])
  18. {
  19. if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) echo '<div class="info" id="error">Błąd. Podaj poprawny email.</div>';
  20. elseif(strlen($_POST['text']) < 2) echo '<div class="info" id="error">Błąd. Wpisz wiadomość.</div>';
  21. elseif($_SESSION['time'] > time()-60) echo '<div class="info" id="error">Błąd. Następną wiadomość możesz wysłać za '.($_SESSION['time']-(time()-60)).' sekund.</div>';
  22. else
  23. {
  24. $_SESSION['time'] = time();
  25. echo '<div class="info" id="good">Wiadomość została wysłana.</div>';
  26. @mail($email, 'Kontakt', "Od: ".$_POST['email']." (".$_POST['name'].") \n\r \n\r ".$_POST['text']);
  27. }
  28. }
  29.  
  30.  
  31. '
  32. <form class="form" method="POST">
  33.  
  34. <p class="name">
  35. <input type="text" name="name" id="name" value="'.$_POST['name'].'"/>
  36. <label for="name">Imię i nazwisko</label>
  37. </p>
  38.  
  39. <p class="email">
  40. <input type="text" name="email" id="email" value="'.$_POST['email'].'" />
  41. <label for="email">E-mail</label>
  42. </p>
  43.  
  44. <p class="text">
  45. <textarea name="text">'.$_POST['text'].'</textarea>
  46. </p>
  47.  
  48. <p class="submit">
  49. <input type="submit" name="form_ok" value="Wyślij" />
  50. </p>
  51.  
  52. </form>
  53.  
  54. </body>
  55. </html>
  56. ';
  57. ?>
b4rt3kk
Przykład wprost z manuala...

  1. // To send HTML mail, the Content-type header must be set
  2. $headers = 'MIME-Version: 1.0' . "\r\n";
  3. $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
  4.  
  5. // Additional headers
  6. $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
  7. $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
  8. $headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
  9. $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
  10.  
  11. // Mail it
  12. mail($to, $subject, $message, $headers);


Zmieniłem tylko iso na utf-8.
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.