Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] syntax error - klasa
hhg
post
Post #1





Grupa: Zarejestrowani
Postów: 316
Pomógł: 0
Dołączył: 5.07.2006

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


napisalem moja pierwsza w zyciu klase i od razu dostaje blad (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Cytat
Parse error: syntax error, unexpected T_VARIABLE in /home/bart/public_html/mailing/mail.class.php on line 5
gdzie 5 linia wskazuje na pierwszy przypisanie w klasie

nie pisze ze ta klasa jest juz gotowa ale prosze o wskazowki co moze jeszcze nie zadzialac, i czy te 'public' powinienem gdzies powinienem zmienic na inne?

z gory dzieki za pomoc
  1. <?php
  2.  
  3. class site
  4. {
  5. public $ip = $_SERVER['REMOTE_ADDR'];
  6. public $host = $gethostbyaddr($this->ip);
  7.  
  8. public $subject;
  9. public $firm;
  10. public $name;
  11. public $telephone;
  12. public $sender;
  13. public $receiver;
  14.  
  15. public function validate($attribute)
  16. {
  17. if (empty($attribute))
  18. return false;
  19. else
  20. return true;
  21. }
  22.  
  23. public $text = nl2br("
  24. Wiadomosc od: $this->sender
  25. Firma: $this->firm
  26. Telefon: $this->telephone
  27. Imie i nazwisko: $this->name
  28.  
  29. $this->text;
  30.  
  31. IP nadawcy: $this->ip
  32. HOST nadawcy: $this->host
  33. ");
  34.  
  35. public function $mailto()
  36. {
  37.  
  38. if (!(validate($this->subject) && validate($this->firm) && validate($this->name) && validate($this->telephone) && validate($this->sender) && validate($this->receiver)))
  39. {
  40. echo "Wszystkie pola sa wymagane. Popaw wprowadzone dane!";
  41. exit();
  42. }
  43.  
  44. $headers = "MIME-Version: 1.0 rn Content-type: text/html; charset=iso-8859-2 rn From: $this->sender rn";
  45.  
  46. if (mail($this->receiver;$this->subject;$this->text;$headers))
  47. echo "email zostal pomyslnie wyslany";
  48.  
  49. }
  50.  
  51. }
  52.  
  53.  
  54.  
  55.  
  56. ?>


Ten post edytował hhg 7.01.2007, 04:17:14
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
hhg
post
Post #2





Grupa: Zarejestrowani
Postów: 316
Pomógł: 0
Dołączył: 5.07.2006

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


wszystko pod php5


dobra dzieki wprowadzilem poprawki i maile sa wysylane (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) (IMG:http://forum.php.pl/style_emoticons/default/exclamation.gif) ! niestety nie widac od kogo sa te maile tylko apache sa wstawiane jakby za zmienna $this->sender, ale to juz wina serwera prawda?

jeszcze mam do Was pytanie ktore zmienna i funkcje bezpieczniej byloby poprzedzic 'protected' lub 'private'

oto obecny kod


  1. <?php
  2. class mailing
  3. {
  4.  
  5. public $ip;
  6. public $host;
  7. public $text;
  8.  
  9. public function __construct()
  10. {
  11. $this -> ip = $_SERVER['REMOTE_ADDR'];
  12. $this -> host = gethostbyaddr($this->ip);
  13. $this -> text = nl2br("
  14. Wiadomosc od: $this->sender
  15. Firma: $this->firm
  16. Telefon: $this->telephone
  17. Imie i nazwisko: $this->name
  18.  
  19. $this->text
  20.  
  21. IP nadawcy: $this->ip
  22. HOST nadawcy: $this->host
  23. ");
  24. }
  25.  
  26. public $subject;
  27. public $firm;
  28. public $name;
  29. public $telephone;
  30. public $sender;
  31. public $receiver;
  32.  
  33. public function validate($attribute)
  34. {
  35. if (empty($attribute))
  36. return false;
  37. else
  38. return true;
  39. }
  40.  
  41. public 
  42.  
  43. public function mailto()
  44. {
  45.  
  46. if (!($this->validate($this->subject) && $this->validate($this->firm) && $this->validate($this->name) && $this->validate($this->telephone) && $this->validate($this->sender) && $this->validate($this->receiver)))
  47. {
  48. echo "Wszystkie pola sa wymagane. Popaw wprowadzone dane!";
  49. exit();
  50. }
  51.  
  52. $headers = "MIME-Version: 1.0 rn Content-type: text/html; charset=iso-8859-2 rn From: $this->sender rn";
  53.  
  54. if (mail($this->receiver,$this->subject,$this->text,$headers))
  55. echo "email zostal pomyslnie wyslany";
  56.  
  57. }
  58.  
  59. }
  60.  
  61.  
  62. $mojmail = new mailing();
  63. $mojmail -> subject = 'temat wiadomosci';
  64. $mojmail -> firm = 'nazwa firmy qwrewrwer';
  65. $mojmail -> name = 'Jan Kowalski';
  66. $mojmail -> telephone = '666';
  67. $mojmail -> sender = 'james@bond.com';
  68. $mojmail -> receiver = 'MOJ@ADRES.PL';
  69. $mojmail -> mailto();
  70. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 16.10.2025 - 00:05