Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Zle wykonywanie sie kodu
perabo
post 11.05.2008, 19:40:01
Post #1





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 11.05.2008

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


Mam taki kod:

  1. <?php 
  2.  
  3. if($_GET['status'] === 'FAIL')
  4. {
  5. echo 'Blad.';
  6. header("Refresh: 2; www.adres.pl");
  7. }
  8. else{
  9.  
  10. $do = $_POST['email'];
  11. $wiadomosc = 'wiadomosc';
  12.  
  13. $naglowki = 'MIME-Version: 1.0' . "\n";
  14. $naglowki .= 'Content-type: text/html; charset=iso-8859-2' . "\n";
  15. $naglowki .= 'From: mail' . "\n" . 'Reply-To: mail';
  16. $temat = 'Dzieki';
  17. echo 'Sprawdz emaila ;))';
  18. mail($do, $temat, $wiadomosc, $naglowki);
  19. }
  20. ?>


Gdy wejde pod adres cos.php?status=FAIL wysyla emaila a nie powinien, dleczego tak się dzieje?

Ten post edytował perabo 11.05.2008, 19:40:53
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 14)
bim2
post 11.05.2008, 19:42:45
Post #2





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


Nie
===
a
==

smile.gif
3 "równa się" porównuje typy np true===false
a 2 "równa się" to porównator logiczny (dobrze napisałem?) smile.gif


--------------------
Go to the top of the page
+Quote Post
perabo
post 11.05.2008, 19:45:24
Post #3





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 11.05.2008

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


Zmieniłem to na == i dalej wysyla meila ;/
Go to the top of the page
+Quote Post
piotrooo89
post 11.05.2008, 19:45:53
Post #4


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




=== argumenty tych samych typów sa równe

== argumenty sa równe

a może sprawdz czy nie jest puste?

  1. <?php
  2. if (!empty($_GET['status']))
  3. {
  4. if($_GET['status'] == 'FAIL')
  5. {
  6. echo 'Blad.';
  7. header("Refresh: 2; www.adres.pl");
  8. }
  9. else{
  10.  
  11. $do = $_POST['email'];
  12. $wiadomosc = 'wiadomosc';
  13.  
  14. $naglowki = 'MIME-Version: 1.0' . "\n";
  15. $naglowki .= 'Content-type: text/html; charset=iso-8859-2' . "\n";
  16. $naglowki .= 'From: mail' . "\n" . 'Reply-To: mail';
  17. $temat = 'Dzieki';
  18. echo 'Sprawdz emaila ;))';
  19. mail($do, $temat, $wiadomosc, $naglowki);
  20. }
  21. }
  22. ?>


Ten post edytował piotrooo89 11.05.2008, 19:54:21


--------------------
Go to the top of the page
+Quote Post
perabo
post 11.05.2008, 19:52:16
Post #5





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 11.05.2008

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


piotrooo89 - teraz się już nie wysyła mail.. no ale gdy np. status=OK to też nie wysyła a powinien wysłać...
Go to the top of the page
+Quote Post
webdice
post 11.05.2008, 19:54:19
Post #6


Developer


Grupa: Moderatorzy
Postów: 3 045
Pomógł: 290
Dołączył: 20.01.2007




Bo ma być:

  1. <?php
  2. if (!empty($_GET['status']))
  3. ?>


Popatrz czasem co kopiujesz.
Go to the top of the page
+Quote Post
piotrooo89
post 11.05.2008, 19:59:52
Post #7


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




to może spróbuj porównać ciągi

  1. <?php
  2. if (!empty($_GET['status']))
  3. {
  4. $status = $_GET['status'];
  5. if(strcasecmp($status, "FAIL")==0)
  6. {
  7. echo 'Blad.';
  8. header("Refresh: 2; www.adres.pl");
  9. }
  10. else{
  11.  
  12. $do = $_POST['email'];
  13. $wiadomosc = 'wiadomosc';
  14.  
  15. $naglowki = 'MIME-Version: 1.0' . "\n";
  16. $naglowki .= 'Content-type: text/html; charset=iso-8859-2' . "\n";
  17. $naglowki .= 'From: mail' . "\n" . 'Reply-To: mail';
  18. $temat = 'Dzieki';
  19. echo 'Sprawdz emaila ;))';
  20. mail($do, $temat, $wiadomosc, $naglowki);
  21. }
  22. }
  23. ?>


ta funkcja porównuj ciągi nie zwracając uwagi na wielkość liter. pisane z palca może chodzić ale nie musi.

Ten post edytował piotrooo89 11.05.2008, 20:00:41


--------------------
Go to the top of the page
+Quote Post
perabo
post 11.05.2008, 20:03:21
Post #8





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 11.05.2008

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


Cytat
to może spróbuj porównać ciągi

Niestety nie działa... Nic nie jest wysylane nawet gdy STATUS= cos innego niz FAIL


Mam teraz tak i też jest problem z tym wysylaniem.

  1. <?php
  2. if (!empty($_GET['status']))
  3. {
  4. if($_GET['status'] == 'FAIL')
  5. {
  6. echo 'Blad.';
  7. header("Refresh: 2; www.adres.pl");
  8. }
  9. else{
  10.  
  11. $do = $_POST['email'];
  12. $wiadomosc = 'wiadomosc';
  13.  
  14. $naglowki = 'MIME-Version: 1.0' . "\n";
  15. $naglowki .= 'Content-type: text/html; charset=iso-8859-2' . "\n";
  16. $naglowki .= 'From: mail' . "\n" . 'Reply-To: mail';
  17. $temat = 'Dzieki';
  18. echo 'Sprawdz emaila ;))';
  19. mail($do, $temat, $wiadomosc, $naglowki);
  20. }
  21. }
  22. ?>
Go to the top of the page
+Quote Post
.radex
post 11.05.2008, 20:03:57
Post #9





Grupa: Zarejestrowani
Postów: 1 657
Pomógł: 125
Dołączył: 29.04.2006

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


Cytat(bim2 @ 11.05.2008, 20:42:45 ) *
3 "równa się" porównuje typy np true===false
a 2 "równa się" to porównator logiczny (dobrze napisałem?) smile.gif


Od kiedy === nie jest operatorem logicznym? Jedyną różnicą w stusunku do == jest patrzenie na typ.

2 == true

ale

2 nie jest === true

smile.gif

Ten post edytował radex_p 11.05.2008, 20:04:06


--------------------
blog | Tadam — minutnik do Pomodoro na Maka :)
Go to the top of the page
+Quote Post
bim2
post 11.05.2008, 20:06:11
Post #10





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


@up
Dlatego się spytałem czy dobrze? snitch.gif

A tak?
  1. <?php 
  2.  
  3. if(isset($_GET['status']) AND $_GET['status'] == 'FAIL')
  4. {
  5. echo 'Blad.';
  6. header("Refresh: 2; www.adres.pl");
  7. }
  8. elseif(isset($_GET['status']) AND $_GET['status'] != 'FAIL'){
  9.  
  10. $do = $_POST['email'];
  11. $wiadomosc = 'wiadomosc';
  12.  
  13. $naglowki = 'MIME-Version: 1.0' . "\n";
  14. $naglowki .= 'Content-type: text/html; charset=iso-8859-2' . "\n";
  15. $naglowki .= 'From: mail' . "\n" . 'Reply-To: mail';
  16. $temat = 'Dzieki';
  17. echo 'Sprawdz emaila ;))';
  18. mail($do, $temat, $wiadomosc, $naglowki);
  19. }
  20. ?>


Ten post edytował bim2 11.05.2008, 20:06:47


--------------------
Go to the top of the page
+Quote Post
perabo
post 11.05.2008, 20:10:59
Post #11





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 11.05.2008

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


bim2 - nie nie wysyła teraz wiadomości nawet gdy status= inny niż FAIL
Go to the top of the page
+Quote Post
piotrooo89
post 11.05.2008, 20:13:07
Post #12


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




pokaż jaki masz kod? to może narazie porównaj wpisując recznie w if'a.

  1. <?php
  2. $s = 'FAIL';
  3.  
  4. if($s == 'FAIL')
  5. ?>


--------------------
Go to the top of the page
+Quote Post
perabo
post 11.05.2008, 20:15:16
Post #13





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 11.05.2008

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


Ok mój kod to:

  1. <?php 
  2.  
  3.  
  4. if(isset($_GET['status']) AND $_GET['status'] == 'FAIL')
  5. {
  6. echo 'Blad';
  7. header("Refresh: 2; adres.pl");
  8. }
  9. elseif(isset($_GET['status']) AND $_GET['status'] != 'FAIL')
  10. {
  11.  
  12. $do = $_POST['email'];
  13. $wiadomosc = 'wiadomosc';
  14.  
  15. $naglowki = 'MIME-Version: 1.0' . "\n";
  16. $naglowki .= 'Content-type: text/html; charset=iso-8859-2' . "\n";
  17. $naglowki .= 'mail' . "\n" . 'Reply-To: mail';
  18. $temat = 'Dzieki';
  19. echo 'Sprawdz emaila ;))';
  20. mail($do, $temat, $wiadomosc, $naglowki);
  21. }
  22.  
  23.  
  24. ?>


Ten post edytował perabo 11.05.2008, 20:15:54
Go to the top of the page
+Quote Post
piotrooo89
post 11.05.2008, 20:16:57
Post #14


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




a może zrob tak:

  1. <?php
  2. if ( (isset($_GET['status']) AND ($_GET['status'] == 'FAIL') )
  3. ?>


Ten post edytował piotrooo89 11.05.2008, 20:17:07


--------------------
Go to the top of the page
+Quote Post
perabo
post 11.05.2008, 20:43:36
Post #15





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 11.05.2008

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


Cytat
Parse error: syntax error, unexpected '{' in ... on line 6


Kod:

  1. <?php 
  2.  
  3.  
  4. if ( (isset($_GET['status']) AND ($_GET['status'] == 'FAIL') )
  5. {
  6. echo 'Blad';
  7. header("Refresh: 2; adres.pl");
  8. }
  9. elseif( (isset($_GET['status']) AND ($_GET['status'] != 'FAIL') )
  10. {
  11.  
  12. $do = $_POST['email'];
  13. $wiadomosc = 'wiadomosc';
  14.  
  15. $naglowki = 'MIME-Version: 1.0' . "\n";
  16. $naglowki .= 'Content-type: text/html; charset=iso-8859-2' . "\n";
  17. $naglowki .= 'mail' . "\n" . 'Reply-To: mail';
  18. $temat = 'Dzieki';
  19. echo 'Sprawdz emaila ;))';
  20. mail($do, $temat, $wiadomosc, $naglowki);
  21. }
  22.  
  23.  
  24. ?>


Nie wiem jakim cudem, ale zmieniłem wszystko z $_GET['status'] na $_POST['status'] i teraz wszystko działa, jednakże dzięki za pomoc.
Go to the top of the page
+Quote Post

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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 06:08