fragment kodu odpowiedzialny za dodawanie i wyswietlanie newsow:
<? $q = \"SELECT com_autor, com_contents, add_c_date, user_ip FROM comments WHERE com
_ ews_id ='$_GET[id_commnts]' ORDER BY com_num DESC\"; $w = mysql_query($q); if(!$w) error_message(sql_error()); else { while ($q = mysql_fetch_array($w)) { $c_autor = $q[\"com_autor\"]; $zawartosc_kom = $q[\"com_contents\"]; $addc_data = $q[\"add_c_date\"]; $u_ip = $q[\"user_ip\"]; ?> <font style=\"margin-left: 5pt; font-family: Verdana; font-size: 9pt; color: gray;\"><b>Data: <? echo \"$addc_data\"; ?> </b> <font style=\"margin-left: 5pt; font-family: Verdana; font-size: 9px; color: darkgray;\">Autor: <? echo \"$c_autor\"; ?> <br> <table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"480\"> <tr> <td align=\"center\" width=\"480\"> <table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"450\"> <tr> <td align=\"center\" width=\"450\"> <DIV ALIGN=\"justify\"> <font style=\"font-family: Verdana; font-size: 10px; color: gray;\"> </div> </td> </tr> </table> </td> </tr> </table> <center> <img src=\"layout/l.jpg\"> </center> <br> <?php } } ?> <input type=\"hidden\" name=\"a\" value=\"add_comment\"> <table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"95%\" height=\"10%\" align=\"center\" valign=\"top\"> <tr> <th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Nick:</th> <td width=\"70%\"><input type=\"text\" name=\"nick\" size=\"20\" maxlenght=\"20\" class=\"pollItem\"></td> </tr> <tr> <th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Komentarz:</th> <td width=\"70%\"> <textarea rows=\"5\" cols=\"40\" name=\"com_zawartosc\" class=\"pollItem\"></textarea></td> </tr> <tr> <th width=\"30%\" colspan=\"2\" NOWRAP> <input type=\"submit\" class=\"pollButton\" value=\"Zapisz\" onmouseover=\"this.className='pollButton-over'\" onmouseout=\"this.className='pollButton'\"> </tr> </table> </form> <?php function add_comment() { $query = \"INSERT INTO comments VALUES(NULL, '$nick', '$com_zawartosc', curdate(), '$_GET[id_commnts]', '\"$REMOTE_ADDR\"'\"; if(!$wynik) error_message(sql_error()); } switch($a) { case \"add_comment\": add_comment(); break; } ?>
Jak wpisze nick i zawartosc komentarza, po naciesnieciu zapisz wyswietla sie tylko dalsza czesc newsa i formularz dodawania komentarzy, a w bazie danych nie ma zadnych nowych danych.
Edit.
Juz wszystko dziala. Zmienilem troche kod i jest ok.
Tylko nie pobiera ip uzytkownika.
pzdr