Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Sprawdzanie $_GET z linku
Arhimenrius
post
Post #1





Grupa: Zarejestrowani
Postów: 115
Pomógł: 3
Dołączył: 19.04.2011

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


Więc. Mam takowy problem, że mam zadeklarowany kontroler, że jeżeli jakiś $_GET jest, to coś ma robić.
No ale jak sprawić, by coś robił, gdy nie ma jakiegokolwiek $_GET?, tzn. jest czyste nazwastrony.pl a nie nazwastrony.pl/?zapytanie=wartosc.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Arhimenrius
post
Post #2





Grupa: Zarejestrowani
Postów: 115
Pomógł: 3
Dołączył: 19.04.2011

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


  1. <!-- box na tekst po prawej -->
  2. <div class="menu_rigth_box">
  3. <!-- Wyświetlanie całych kategorii -->
  4. <? if($_GET['cat'] || $_SERVER['REQUEST_METHOD'] !='GET')
  5. {
  6. echo '<h2>'.$category_title.'</h2>';
  7. //artykuł
  8. for($i=0;$i<count($article);$i++)
  9. {
  10. ?>
  11. <div class="menu_right_name">
  12. <div id="name">
  13. <span class="title"><a href="#"><? echo $article[$i]['article_title']; ?></a></span><span class="category"><a href="#"><? echo $article[$i]['article_category']; ?></a></span><span class="date"><? echo $article[$i]['article_date']; ?></span>
  14. </div>
  15. </div>
  16. <div class="menu_right_center">
  17. <div id="page">
  18. <?
  19. if($error != '')
  20. echo '<h3>'.$error.'</h3>';
  21. else
  22. echo $article[$i]['article_article'];
  23. ?>
  24. </div>
  25. </div>
  26. <div class="menu_right_bottom">
  27. </div>
  28. <?
  29. }
  30. }
  31. //Wyświetlanie pojedyńczych stron
  32. elseif($_GET['pag'])
  33. {
  34. ?>
  35. <div class="menu_right_name">
  36. <div id="name">
  37. <span class="title"><a href="#"><? echo $page_title; ?></a></span></span>
  38. </div>
  39. </div>
  40. <div class="menu_right_center">
  41. <div id="page">
  42. <?
  43. if($error != '')
  44. echo '<h3>'.$error.'</h3>';
  45. else
  46. echo $page_text; ?>
  47. </div>
  48. </div>
  49. <div class="menu_right_bottom">
  50. </div>
  51. <?
  52. }
  53.  
  54. ?>
  55. <!-- koniec artykułu -->
  56.  
  57. </div>
  58. <br class="clear">
  59.  
  60. </div>
  61. </div>


i potem controller_page.php
  1. if($_GET['pag'])
  2. {
  3. if(@!include_once 'cache/pag'.$_GET['pag'].'.php')
  4. {
  5. $error = '404 - Nie ma takiej strony';
  6. }
  7. }
  8. elseif($_GET['cat'])
  9. {
  10. if(@!include_once 'cache/cat'.$_GET['cat'].'.php')
  11. {
  12. $error = '404 - Nie ma takiej strony';
  13. }
  14. }
  15. elseif( $_SERVER['REQUEST_METHOD'] !='GET')
  16. {
  17. @include_once 'cache/articles.php';
  18. }

Pliki z zapytania cat i z articles.php mają podobną budowę, więc działają tak samo.
Go to the top of the page
+Quote Post

Posty w temacie


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: 27.12.2025 - 21:08