Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php]blad naglowki wyslane[php]jak tpo naprawic?
Forum PHP.pl > Forum > Przedszkole
martino277
siemka!!! mam taki blad wiem ze to oznacza naglowki wyslane i ze niemoze zmodyfikowac informacji w ale jak to naprawic to niewiem niewiem:Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\WebServ\httpd\class.SimpleMail.php:84) in C:\Program Files\WebServ\httpd\admin_transact.php on line 93
to jest kod admin_transact.php
  1. <?php
  2. require('config.php');
  3. require('class.SimpleMail.php');
  4.  
  5. $conn = mysql_connect(SQL_HOST,SQL_USER,SQL_PASS)
  6. or die('Nie moge polączya sie z bazą danych:' . mysql_error());
  7.  
  8. mysql_select_db(SQL_DB,$conn);
  9.  
  10. if(isset($_POST['action'])) {
  11. switch($_POST['action']) {
  12. case 'Dodaj nową listę mailingową':
  13. $sql = "INSERT INTO ml_lists (listname) " .
  14. "VALUES ('" .$_POST['listname']."')";
  15. or die('Nie mogę dodać listy mailingowej.' . mysql_error());
  16. break;
  17. case 'Usuń listę mailingową':
  18. $sql = "DELETE FROM ml_lists WHERE ml_id=" . $_POST['ml_id'];
  19. or die('Nie mogę usunąć z listy mailingowej.' . mysql_error());
  20. $sql = "DELETE FROM ml_subscriptions " .
  21.  "WHERE ml_id=" . $_POST['ml_id'];
  22. or die('Nie mogę usunąć subskrypcji listy mailingowej.' . mysql_error());
  23. break;
  24.  
  25.  
  26. case 'Wyslij wiadomosć';
  27.  if(isset($_POST['msg'], $_POST['ml_id'])) {
  28. if(is_numeric($_POST['ml_id'])) {
  29. $sql = "SELECT listname FROM ml_lists" .
  30.  "WHERE ml_id='" . $_POST['ml_id'] ."'";
  31. $result = mysql_query($sql,$conn)
  32. or die(mysql_error());
  33. $row = mysql_fetch_array($result);
  34. $listname = $row['listname'];
  35. } else {
  36.  $listname = "Główna";
  37.  }
  38.  
  39.  $sql = "SELECT DISTINCT usr.email,usr.firstname.usr.user_id " .
  40. "FROM ml_users usr " .
  41. "INNER JOIN ml_subscriptions mls" .
  42. "ON usr.user_id = mls.user_id " .
  43. "WHERE mls.pending=0";
  44. if ($_POST['ml_id'] != 'all') {
  45. $sql .= "AND mls.ml_id=" .$_POST['ml_id'];
  46. }
  47.  
  48. $result = mysql_query($sql)
  49. or die('Nie potrafię uzyskać listy adresów email' .
  50.  
  51.  
  52. $headers = "From: " . ADMIN_EMAIL ."r\n";
  53.  
  54. while ($row = mysql_fetch_array($result)) {
  55. if (is_numeric($_POST['ml_id'])) {
  56. $ft = "Otrzymujesz tą wiadomosć jako członek listy mailingowej";
  57. $ft .= $listname .".\n Jeżeli uważasz, że ten list został ";
  58. $ft .= "wysłany pod zły adres lub\n chcesz usunąć ";
  59. $ft .= "swój adres z listy mailingowej, odwiedż poniższy ";
  60. $ft .= " link:\n";
  61. $ft .= "http://" .$_SERVER['HTTP_HOST'].
  62. dirname($_SERVER['PHP_SELF']) . "/remove.php?u=" .
  63. $row['user_id'] . "&ml=" . $_POST['ml_id'];
  64. } else {
  65. $ft = "Otrzymujesz tą wiadomosć bo zapisałes się do jednej";
  66. $ft .= "lub wielu list mailingowych.\n Odwiedż poniższy ";
  67. $ft .= "link, aby zmienic ustawienia swojej subskrypcji:\n";
  68. $ft .= "http://" . $_SERVER['HTTP_HOST'] .
  69.  dirname($_SERVER['PHP_SELF']) . "/user.php?u=" .
  70.  $row['user_id'];
  71. }
  72. $msg = stripslashes($_POST['msg']) . "\n\n";
  73. $msg .= "--------------\n";
  74. $msg .= $ft;
  75.  
  76. $email = new SimpleMail();
  77.  
  78. $email->send($row['email'],
  79.  stripslashes($_POST['subject']),
  80.  $msg,
  81.  $headers)
  82. or die('Wysłanie emaila nie powiodło się.');
  83. }
  84. }
  85. break;
  86. }
  87. }
  88.  
  89. header('Location: admin.php');
  90. ?>


i podaje tez ten drugi kod tej clasy na wszelki wypadek
  1. <?php
  2.  
  3. class SimpleMail {
  4. public $to = NULL;
  5. public $cc = NULL;
  6. public $bcc = NULL;
  7. public $from = NULL;
  8. public $subject = '';
  9. public $body = '';
  10.  
  11.  
  12. public $htmlbody = '';
  13. public $send_text = TRUE;
  14. public $send_html = FALSE;
  15. private $message = '';
  16. private $headers = '';
  17.  
  18. public function send($to = NULL,
  19. $subject = NULL,
  20. $message = NULL,
  21. $headers = NULL) {
  22. if(func_num_args() >= 3) {
  23. $this->to = $to;
  24. $this->subject = $subject;
  25. $this->message = $message;
  26. if ($headers) {
  27. $this->headers = $headers;
  28. }
  29.  
  30. } else {
  31.  
  32. if ($this->from) {
  33. $this->headers .= "From: " . $this->from ."r\n";
  34. }
  35.  
  36. if ($this->cc) {
  37. $this->headers .= "Cc: " . $this->cc ."r\n";
  38. }
  39.  
  40. if ($this->bcc) {
  41. $this->headers .= "Bcc: " . $this->bcc ."r\n";
  42. }
  43.  
  44. if ($this->send_text and !$this->send_html) {
  45. $this->message = $this->body;
  46. } elseif ($this->send_html and !$this->send_text) {
  47. $this->message = $this->htmlbody;
  48. $this->headers .= "MIME-Version: 1.0r\n";
  49. $this->headers .= "Content-type: text/html;" .
  50. "charset=iso-8859-2r\n";
  51. } else {
  52. $_boundary = "==MP_Bound_xyccr948x==";
  53. $this->headers = "MIME-Version: 1.0r\n";
  54. $this->headers .= "Content-type: multipart/alternative;" .
  55.  "boundary=\"$_boundary\"r\n";
  56.  
  57. $this->message = "Jest to wiadomosć wieloczęsciowa w" .
  58. "formacie MIME\n";
  59. $this->message .= "--$_boundary\n";
  60. $this->message .= "Content-type: text/plain;" .
  61. "charset=\"iso-8859-2\"\n";
  62. $this->message .= "Content-Transfer-Encoding: 8bit\n\n";
  63. $this->message .= $this->body . "\n";
  64. $this->message .= "--$_boundary\n";
  65. $this->message .= "Content-type: text/html;" .
  66. "charset=\"iso-8859-2\"\n";
  67. $this->message .= "Content-Transfer-Encoding: 8bit\n\n";
  68. $this->message .= $this->htmlbody . "\n";
  69. $this->message .= "--$_boundary--";
  70.  }
  71.  }
  72.  
  73.  if (!mail($this->to.$this->subject,$this->message,$this->headers)) {
  74.  throw new Exception('Wysłanie listu zakończone niepowodzeniem.');
  75.  return FALSE;
  76.  } else {
  77.  return TRUE;
  78. }
  79. }
  80. }
  81. ?>


jezeli by mi ktos wyjasnil co musze poprawic bylbym wdzieczny pozdrawiam
strife
Szukałeś chociaż? http://phpedia.pl/wiki.php?title=Cannot_ad...rs_already_sent. Zamykam ten temat, aby oszczędzić niektórym nerwów po widoku n'ty raz pytania o nagłówki happy.gif

Zamykam.
(potem wywalę)
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.