mam plik autor.php, w ktorym mam dwa linki:
Kod
<a href="autor2.php?link=komentarze">0</a>
<a href="autor2.php?link=dodaj">dodaj</a>
<a href="autor2.php?link=dodaj">dodaj</a>
oba linki prowadza, zreszta co widac, do tego samego pliku - autor2.php.
w pliku tym mam skrypty, ktore w zaleznosci od wartosci zmiennej $link includuja odpowiedni pliki.
problem twki w tym, ze pliki sa includowane poprawnie, bo jezeli $link == 'dodaj' to wyswietla mi formularz, ale nie chce go obslugiwac. kod formularza i obslugujacy go sa includowane.
po prawidlowym wypelnieniu powinno mnie przeniesc do autor2.php?link=komentarze, a po blednym, powinny pojawic sie informacje o bledzie, a tymczasem przenosi mnie do... autor.php.
dlaczego tak jest? gdzie jest blad?
ponizej jest caly kod wszystkich plikow
autor2.php
<?php header (\"Location: http://\" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . \"/autor.php\"); } else { switch (($_GET['link'])) { case 'dodaj': $strona = 'autor - dodaj komentarz'; break; case 'komentarze': $strona = 'autor - komentarze'; break; } } //koniec if (($_GET['link']) == 'dodaj') { include ('inc/autor_dodaj1.inc'); } include ('inc/head.inc'); $bg_color = 'bg_color' . $bg_color . '.css'; include ('inc/dane.inc'); include ('inc/data.inc'); include ('inc/zegar.inc'); ?> <script language=\"JavaScript\"> // by Jakub var szer=screen.width if (szer<=800) document.write('<link rel=\"stylesheet\" type=\"text/css\" href=\"css/800.css\">'); if (szer>800&&szer<=1024) document.write('<link rel=\"stylesheet\" type=\"text/css\" href=\"css/1024.css\">'); if (szer>1024) document.write('<link rel=\"stylesheet\" type=\"text/css\" href=\"css/1280.css\">'); </script> <?php if (($_GET['link']) == 'dodaj') { } elseif (($_GET['link']) == 'komentarze') { } ?> </head> <body onLoad=\"show5()\"> <!-- cale okno --> <div id=\"okno1\"> <!-- okno wlasciwe --> <div id=\"okno2\"> <!-- gora --> <div id=\"g_tlo\"> <div id=\"g_menu\"> <?php include ('inc/g_menu.inc'); ?> </div> </div> <!-- /gora --> <!-- srodek --> <!-- srodek s_kolumna1 --> <div id=\"s_kolumna1\"> <table id=\"dataiczas\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td id=\"data\"> <?php ?></td> <td id=\"zegar\"> <span id=\"liveclock\"></span></td> </tr> </table> <!-- srodek s_kolumna1 s_naglowek --> <div id=\"s_naglowek\"> </div> <!-- /srodek s_kolumna1 s_naglowek --> <!-- srodek s_kolumna1 s_okno --> <div id=\"s_okno\"> <?php } if (($_GET['link']) == 'dodaj') { include('inc/autor_dodaj2.inc'); } elseif (($_GET['link']) == 'komentarze') { include('inc/autor_komentarze2.inc'); } ?> </div> <!-- /srodek s_kolumna1 s_okno --> </div> <!-- /srodek s_kolumna1 --> <!-- srodek s_kolumna2 --> <div id=\"s_kolumna2\"> <div id=\"s_menu\"> <?php include ('inc/s_menu1.inc'); include ('inc/s_menu2.inc'); include ('inc/s_menu3.inc'); ?> </div> <!-- /srodek s_kolumna2 --> </div> <!-- /srodek --> <!-- dol --> <div id=\"d_tlo\"> <div id=\"d_menu\"> <?php include ('inc/d_menu.inc'); ?> </div> <div id=\"d_prawa\"> </div> </div> <!-- /dol --> </div> <!-- /okno wlasciwe --> </div> <!-- /cale okno --> </body> </html>
autor_dodaj1.inc - obslugujacy formularz:
<?php $message = NULL; $nick1 = $_POST['nick']; } else { $nick1 = FALSE; $message .= 'podaj imię i nazwisko lub nick.' . '<br />'; } $email1 = $_POST['email']; } else { $email1 = FALSE; $message .= 'podaj swój adres e-mail.' . '<br />'; } $tresc1 = $_POST['tresc']; } else { $tresc1 = FALSE; $message .= 'podaj tresc komentarza.' . '<br />'; } if ($data && $nick1 && $email1 && $tresc1) { require_once('../kuba1.php'); $query = \"INSERT INTO autor_komentarze (data, nick, email, adres, tresc) VALUES (NOW(), '$nick1', '$email1', '$adres1', '$tresc1')\"; if ($result) { header (\"Location: http://\" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . \"/autor2.php?link=komentarze\"); } else { $message = 'awaria systemu.' . '<br />'; } } else { $message .= 'wypełnij formularz jeszcze raz.' . '<br />'; } } ?>
autor_dodaj2.inc - kod formularza:
<table cellspacing=\"0\" cellpadding=\"0\"> <tr> <td class=\"lewa\">imię i nazwisko lub nick:</td> </tr> <tr> <td class=\"lewa\">e-mail:</td> </tr> <tr> <td class=\"lewa\">adres strony www:</td> </tr> <tr> <td class=\"lewa\">tre¶ć:</td> </tr> <tr> <td class=\"lewa\"> </td> <td class=\"prawa\"><input type=\"submit\" name=\"wyslij\" value=\"dodaj\" /></td> </tr> </table> </form>