Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] formularz kontaktowy
Forum PHP.pl > Forum > Przedszkole
onyx
witam

Próbuję zrobić formularz na stronę www - taki co można wysłać z www bez użycia programu pocztowego. Ściągnęłem jakis przykład z netu, zrobiłem cały formularz w html, wrzucam na www i wyrzuca 2 błędy - w 91 i 95 linijce. Co ciekawe mail wysyła tylko w przeglądarce pojawiają się błędy. Kod wygląda mniej więcej tak:

  1. <?php
  2. $MailToAddress = "adres@adres.pl";
  3. $redirectURL = "http://www.adres.pl";
  4. $MailSubject = "Zapytanie z adres.pl";
  5. $sendHTML = FALSE;
  6. $serverCheck = TRUE;
  7.  
  8. $w4fver = "2.2";
  9.  
  10. $w4fx = stristr(file_get_contents('blockip.txt'),getenv('REMOTE_ADDR'));
  11. if ($serverCheck) {
  12. if (preg_match ("/".str_replace("www.", "", $_SERVER["SERVER_NAME"])."/i", $_SERVER["HTTP_REFERER"])) { $w4fy = TRUE; } else { $w4fy = FALSE; }
  13. } else { $w4fy = TRUE; }
  14. if (($w4fy === TRUE) && ($w4fx === FALSE)) {
  15. $w4fMessage = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html>\n<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head><body><font face=3Dverdana size=3D2>";
  16. if (count($_GET) >0) {
  17. reset($_GET);
  18. while(list($key, $val) = each($_GET)) {
  19. $GLOBALS[$key] = $val;
  20. if (is_array($val)) {
  21. $w4fMessage .= "<b>$key:</b> ";
  22. foreach ($val as $vala) {
  23. $vala =stripslashes($vala);
  24. $vala = htmlspecialchars($vala);
  25. if (trim($vala)) { if (stristr($vala,"Content-Type:") || stristr($vala,"MIME-Version") || stristr($vala,"Content-Transfer-Encoding") || stristr($vala,"bcc:")) { blockip($ip); die("ILLEGAL EXECUTION DETECTED!"); } }
  26. $w4fMessage .= "$vala, ";
  27. }
  28. $w4fMessage .= "<br>\n";
  29. }
  30. else {
  31. $val = stripslashes($val);
  32. if (trim($val)) { if (stristr($val,"Content-Type:") || stristr($val,"MIME-Version") || stristr($val,"Content-Transfer-Encoding") || stristr($val,"bcc:")) { blockip($ip); die("ILLEGAL EXECUTION DETECTED!"); } }
  33. if (($key == "Submit") || ($key == "submit")) { }
  34. else { if ($val == "") { $w4fMessage .= "$key: - <br>\n"; }
  35. else { $w4fMessage .= "<b>$key:</b> $val<br>\n"; }
  36. }
  37. }
  38. } // end while
  39. }//end if
  40. else {
  41. reset($_POST);
  42. while(list($key, $val) = each($_POST)) {
  43. $GLOBALS[$key] = $val;
  44. if (is_array($val)) {
  45. $w4fMessage .= "<b>$key:</b> ";
  46. foreach ($val as $vala) {
  47. $vala =stripslashes($vala);
  48. $vala = htmlspecialchars($vala);
  49. if (trim($vala)) { if (stristr($vala,"Content-Type:") || stristr($vala,"MIME-Version") || stristr($vala,"Content-Transfer-Encoding") || stristr($vala,"bcc:")) {blockip($ip); die("ILLEGAL EXECUTION DETECTED!"); } }
  50. $w4fMessage .= "$vala, ";
  51. }
  52. $w4fMessage .= "<br>\n";
  53. }
  54. else {
  55. $val = stripslashes($val);
  56. if (trim($val)) { if (stristr($val,"Content-Type:") || stristr($val,"MIME-Version") || stristr($val,"Content-Transfer-Encoding") || stristr($val,"bcc:")) {blockip($ip); die("ILLEGAL EXECUTION DETECTED!"); } }
  57. if (($key == "Submit") || ($key == "submit")) { }
  58. else { if ($val == "") { $w4fMessage .= "$key: - <br>\n"; }
  59. else { $w4fMessage .= "<b>$key:</b> $val<br>\n"; }
  60. }
  61. }
  62. } // end while
  63. }//end else
  64. $w4f_what = array("/To:/i", "/Cc:/i", "/Bcc:/i","/Content-Type:/i","/\n/");
  65. $name = preg_replace($w4f_what, "", $dane);
  66. $email = preg_replace($w4f_what, "", $email);
  67. if (!$email) {$email = $MailToAddress;}
  68. $mailHeader = "From: $name <$email>\r\n";
  69. $mailHeader .= "Reply-To: $name <$email>\r\n";
  70. $mailHeader .= "Message-ID: <". md5(rand()."".time()) ."@". ereg_replace("www.","",$_SERVER["SERVER_NAME"]) .">\r\n";
  71. $mailHeader .= "MIME-Version: 1.0\r\n";
  72. if ($sendHTML) {
  73. $mailHeader .= "Content-Type: multipart/alternative;";
  74. $mailHeader .= " boundary=\"----=_NextPart_000_000E_01C5256B.0AEFE730\"\r\n";
  75. }
  76. $mailHeader .= "X-Priority: 3\r\n";
  77. $mailHeader .= "X-Mailer: PHP/" . phpversion()."\r\n";
  78. $mailHeader .= "X-MimeOLE: Produced By Web4Future Easiest Form2Mail $w4fver\r\n";
  79. if ($sendHTML) {
  80. $mailMessage = "This is a multi-part message in MIME format.\r\n\r\n";
  81. $mailMessage .= "------=_NextPart_000_000E_01C5256B.0AEFE730\r\n";
  82. $mailMessage .= "Content-Type: text/plain; charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n";
  83. $mailMessage .= trim(strip_tags($w4fMessage))."\r\n\r\n";
  84. $mailMessage .= "------=_NextPart_000_000E_01C5256B.0AEFE730\r\n";
  85. $mailMessage .= "Content-Type: text/html; charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n";
  86. $mailMessage .= "$w4fMessage\r\n\r\n";
  87. $mailMessage .= "------=_NextPart_000_000E_01C5256B.0AEFE730--\r\n";
  88. }
  89. if ($sendHTML === FALSE) {
  90. $mailHeader .= "Content-Type: text/plain; charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n";
  91. $mailMessage .= trim(strip_tags($w4fMessage))."\r\n\r\n";
  92. }
  93.  
  94. if (!mail($MailToAddress, $MailSubject, $mailMessage,$mailHeader)) { echo "Error sending e-mail!";}
  95. else { header("Location: ".$redirectURL); }
  96. } else { echo "<center><font face=verdana size=3 color=red><b>ILLEGAL EXECUTION DETECTED!</b></font></center>";}
  97. ?>


Proszę o info co i jak zmienić żeby działał. Z góry dzięki za pomoc.
pozdrawiam
Gość
Napisał byś chociaż jakie błędy.
onyx
faktycznie nie napisałem:)

Notice: Undefined variable: mailMessage in /blablabla/form2mail.php on line 91
Warning: Cannot modify header information - headers already sent by (output started at /home/blablabla/form2mail.php:91) in /home/blablabla/public_html/form2mail.php on line 95
Turson
Co do błędu z "headers already sent" to masz multum odpowiedzi w sieci.
Podpowiem, że chodzi o ob_start() i ob_end_flush()
http://phpedia.pl/wiki/Cannot_add_header_i...rs_already_sent
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.