Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> strony typu index.php?page=
vtuner
post
Post #1





Grupa: Zarejestrowani
Postów: 220
Pomógł: 10
Dołączył: 23.08.2005
Skąd: Łódź

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


mam cos takiego:
  1. <?php
  2. if($chop == $_GET['chop'])
  3. {
  4. if ( $chop == "AMV")
  5. {
  6. include 'amv.php';
  7. }
  8. else if ( $chop == "CPWerks")
  9. {
  10. include 'cpwerks.php';
  11. }
  12. }
  13. else if($page == $_GET['page'])
  14. {
  15. if ( $page == "")
  16. {
  17. include 'start.php';
  18. }
  19. else if( $page == "dupa")
  20. {
  21. include'dupa.php';
  22. }
  23. }
  24.  
  25. ?>


i nie chce mi się wyswietlic start.php przy samym poczatku strony a powinno. Co jest zle?
TZN
Mam tabele w ktorej ma to się wyświetlać. I przy samym stacie strony powinno do tabeli zaincludowac start.php i pokazac jego zawartość a nie pokazuje. Reszta jest wporządku tylko to jedno jest zle.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 8)
sf
post
Post #2





Grupa: Zarejestrowani
Postów: 1 597
Pomógł: 30
Dołączył: 19.02.2003
Skąd: Tychy

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


sam do tego dojdz..

po pierwsze error_reporting(E_ALL), nastepnie var_dump($_GET);, dalej pomiedzy linia 14, a 15 daj var_dump($page)
Go to the top of the page
+Quote Post
vtuner
post
Post #3





Grupa: Zarejestrowani
Postów: 220
Pomógł: 10
Dołączył: 23.08.2005
Skąd: Łódź

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


teraz mam tak
  1. <?php
  2.  
  3. var_dump($_GET);
  4. $chop = $_GET['chop'];
  5. $page = $_GET['page'];
  6. if($chop)
  7. {
  8. if ( $chop == "AMV")
  9. {
  10. include 'amv.php';
  11. }
  12. else if ( $chop == "CPWerks")
  13. {
  14. include 'cpwerks.php';
  15. }
  16. }
  17. else if($page)
  18. {
  19. var_dump($page);
  20. if ( $page == "")
  21. {
  22. include 'start.php';
  23. }
  24. else if( $page == "dupa")
  25. {
  26. include'dupa.php';
  27. }
  28. }
  29. ?>

i takie bledy mi wychodza

2039array(0) { }
Notice: Undefined index: chop in adres_pliku on line 3

Notice: Undefined index: page in adres_pliku on line 4
Go to the top of the page
+Quote Post
Ociu
post
Post #4





Grupa: Moderatorzy
Postów: 1 566
Pomógł: 37
Dołączył: 14.05.2003
Skąd: Kraków




  1. <?php
  2. # na poczatku:
  3. error_reporting( E_ALL );
  4.  
  5. # tam gdzie ma sie to includowac:
  6. if(isset($_GET['strona'])) {
  7. $strona = strtolower($_GET['strona']);
  8. if(file_exists($strona.'php')) include($strona.'.php');
  9. }
  10.  
  11. if(!isset($_GET['chop'])) include('start.php');
  12. $strona = strtolower($_GET['chop']);
  13. if(file_exists($strona.'php')) include($strona.'.php');
  14. ?>
Go to the top of the page
+Quote Post
vtuner
post
Post #5





Grupa: Zarejestrowani
Postów: 220
Pomógł: 10
Dołączył: 23.08.2005
Skąd: Łódź

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


jakos tego nie kapuje mam tak:
  1. <?php
  2. $chop = $_GET['chop'];
  3. if(!empty($_GET['chop']))
  4. {
  5. if ( $chop == "AMV")
  6. {
  7. include 'amv.php';
  8. }
  9. else if ( $chop == "CPWerks")
  10. {
  11. include 'cpwerks.php';
  12. }
  13. else if ( $chop == "Droo")
  14. {
  15. include 'droo.php';
  16. }
  17. else if ( $chop == "FroZ")
  18. {
  19. include 'froz.php';
  20. }
  21. else if ( $chop == "Glacius")
  22. {
  23. include 'glacius.php';
  24. }
  25. else if ( $chop == "GSX4G63")
  26. {
  27. include 'gsx4g63.php';
  28. }
  29. else if ( $chop == "Neo")
  30. {
  31. include 'neo.php';
  32. }
  33. else if ( $chop == "NOM15")
  34. {
  35. include 'nom15.php';
  36. }
  37. else if ( $chop == "Piechur")
  38. {
  39. include 'piechur.php';
  40. }
  41. else if ( $chop == "REW")
  42. {
  43. include 'rew.php';
  44. }
  45. else if ( $chop == "RuiG")
  46. {
  47. include 'ruig.php';
  48. }
  49. else if ( $chop == "Tony-Riley")
  50. {
  51. include 'tonyriley.php';
  52. }
  53. else if ( $chop == "visual")
  54. {
  55. include 'visual.php';
  56. }
  57. else if ( $chop == "Zammo")
  58. {
  59. include 'zammo.php';
  60. }
  61. else if ( $chop == "ZVT")
  62. {
  63. include 'zvt.php';
  64. }
  65. }
  66. else if(!empty($_GET['page']))
  67. {
  68. $page = $_GET['page'];
  69. if ( $page == "tutoriale")
  70. {
  71. include 'tut.php';
  72. }
  73. else if ( $page == "linki")
  74. {
  75. include 'linki.php';
  76. }
  77. else if ( $page == "kontakt")
  78. {
  79. include 'kontakt.php';
  80. }
  81. else
  82. {
  83. echo '<center><FONT FACE="Verdana" SIZE="2" COLOR="Black">Witamy na CarChopDesign!<br></font></center>';
  84. }
  85. ?>

i jak zrobic zeby dzialalo poprawnie??
Go to the top of the page
+Quote Post
Ociu
post
Post #6





Grupa: Moderatorzy
Postów: 1 566
Pomógł: 37
Dołączył: 14.05.2003
Skąd: Kraków




(IMG:http://forum.php.pl/style_emoticons/default/blink.gif)
switch" title="Zobacz w manualu php" target="_manual, include" title="Zobacz w manualu php" target="_manual
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #7





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

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


A o tablicach slyszales? Przeciez ten kod to totalna masakra -- z uzyciem tablic zmiescil bys to w 3 linijkach.
-----
  1. <?php
  2. $chop = $_GET['chop'];
  3. if(!empty($_GET['chop']))
  4.  
  5. ?>

przeciez to jest bez sensu, przypisujesz wartosc nieistniejacej zmiennej a dopiero potem sprawdzasz czy ona istnieje
  1. <?php
  2. if ( isset( $_GET['chop'] )
  3. {
  4.  $chop = $_GET['chop'];
  5. }
  6. else
  7. {
  8. $chop = 'default'; // czy jakas inna wartosc (index, start, itp).
  9. }
  10.  
  11. // resszta kodu
  12.  
  13.  
  14. ?>


Ten post edytował dr_bonzo 27.11.2005, 17:37:03
Go to the top of the page
+Quote Post
vtuner
post
Post #8





Grupa: Zarejestrowani
Postów: 220
Pomógł: 10
Dołączył: 23.08.2005
Skąd: Łódź

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


akurat to:
  1. <?php
  2. $chop = $_GET['chop'];
  3. if(!empty($_GET['chop']))
  4. ?>

podala mi jedna osoba ktora jest developerem na tym forum, wiec w takim razie ta osoba mi podala zle
Go to the top of the page
+Quote Post
dtb
post
Post #9





Grupa: Zarejestrowani
Postów: 476
Pomógł: 1
Dołączył: 5.11.2005
Skąd: Bieruń city

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


  1. <?php
  2. $chop = 
  3. 'AMV'=>'amv.php',
  4. 'cpwerks'=>'cpwerks.php',
  5. );
  6.  
  7. $page
  8. '' => 'start.php',
  9. 'dupa' => 'dupa.php',
  10. );
  11.  
  12. if ($isset ($_GET['chop']);
  13. include ($chop[$_GET['chop']);
  14. elseif ($isset ($_GET['page']);
  15. include ($page[$_GET['page']);
  16. ?>


Ten post edytował dtb 27.11.2005, 20:18:07
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 21.12.2025 - 22:15