Witam mam problem chcialem zrobic zabespieczenie takie ze jak nie wpisze sie np autora to nie dodaje komenta ale wyszedl jakis blad i nie skad on sie wziol oto kod

bład wyglada tak

tresc komenta
}

i nic wiecej

  1. <?
  2.  
  3. include ("config.php");
  4.  
  5. include ("module/artykuly.php");
  6.  
  7. //język//
  8.  
  9. function pokaz()
  10.  
  11. {
  12.  
  13. global $id,$nrnewsa,$zaloguj_login,$co,$text,$ip,$date,$autor,$zaloguj_login;
  14. news_t_open();
  15. echo 'Komentarze Newsów';
  16. news_t_close();
  17. news_tresc_open();
  18.  
  19. $komentarzen_login = $_COOKIE["login_c"];
  20.  
  21.  
  22.  
  23. if ($co == dopisz) {
  24.  
  25. if (!$autor AND !$text) {
  26.  
  27.  echo 'Nie wypełniłeś wszystkich pól....';
  28.  
  29. } else {
  30.  
  31. $text = strip_tags($text);
  32.  
  33. $text = str_replace("", "<b>", $text);
  34.  
  35. $text = str_replace("", "</b>", $text);
  36.  
  37. $text = str_replace("", "<i>", $text);
  38.  
  39. $text = str_replace("", "</i>", $text);
  40.  
  41. $text = str_replace("", "<u>", $text);
  42.  
  43. $text = str_replace("", "</u>", $text);
  44.  
  45.  
  46.  
  47. $text = str_replace("[cytat]", "\"&nbsp;<i>", $text);
  48.  
  49. $text = str_replace("[/cytat]", "</i>&nbsp;", $text);
  50.  
  51. $text = nl2br($text);
  52.  
  53. $query = "INSERT INTO news_kom ( id , text, date , ip , autor, nrnewsa ) VALUES ('', '$text', CURDATE( ), '$ip', '$autor', '$nrnewsa');";
  54.  
  55. $wynikp = mysql_query ($query);
  56.  
  57. $query4 = "UPDATE uzytkownicy SET komentarzy=komentarzy + 1 WHERE login='$zaloguj_login'";
  58.  
  59. $result4 = mysql_query ($query4);
  60.  
  61. echo "<p class=\"articlehead\">Komentarze</p>";
  62.  
  63. echo"</b><br /><br />";
  64. //header("location: comments.php?id=$nrnewsa");
  65. }
  66. news_tresc_close();
  67.  
  68. news_inne_newsow_close();
  69.  
  70.  } else {
  71.  
  72. if ($co == dodaj) {
  73.  
  74. $ip=$_SERVER["REMOTE_ADDR"];
  75.  
  76. echo "<p>&nbsp;Dodaj komentarz</p><br /><br /><form method=\"POST\" action=\"comments.php?co=dopisz\" >
  77.  
  78. <table border=\"0\" width=\"99%\" cellspacing=\"0\" align=\"center\" cellpadding=\"0\">
  79.  
  80. <tr>
  81.  
  82. <td height=\"23\" width=\"45%\">Treść:</td>
  83.  
  84. <td height=\"23\" width=\"55%\">
  85.  
  86. <textarea rows=\"4\" name=\"text\" class=\"textbox\" cols=\"28\"></textarea></td>
  87.  
  88. </tr>
  89.  
  90. <tr>
  91.  
  92. <td height=\"16\" width=\"45%\">Autor:</td>
  93.  
  94. <td height=\"16\" width=\"55%\">";
  95. if (!$_COOKIE["login1_c"])
  96.  
  97. {
  98.  
  99. echo "<input type=\"text\" name=\"autor\" class=\"textbox\" size=\"20\">";
  100.  
  101. }
  102.  
  103. else
  104.  
  105. {
  106.  
  107. echo "$zaloguj_login <input type=\"hidden\" name=\"autor\" class=\"textbox\" size=\"20\" value=\"$zaloguj_login\">";
  108. }
  109.  
  110. echo "<input type=\"hidden\" name=\"nrnewsa\" value=\"$id\"><input type=\"hidden\" name=\"ip\" value=\"$ip\"></td>
  111.  
  112. </tr>
  113.  
  114.  
  115.  
  116. </table><br /><br />";
  117.  
  118. echo "<p align=\"left\" class=\"uni01\"><b>Nie używaj tagów html.</b> Zostaną one automatycznie
  119.  
  120. usunięte!</p>
  121.  
  122. <p>Dozwolone znaczniki BBCODE:</p>
  123.  
  124. <p>Pogrubienie: tekst<br />
  125.  
  126. Pochylenie: tekst<br />
  127.  
  128. Podkreślenie: tekst</p>
  129.  
  130. Cytat: [cytat]tekst[/cytat]<p></p>";
  131.  
  132. echo "<p align=\"center\"><input type=\"submit\" class=\"button\" value=\"Dodaj!\"></p>
  133.  
  134. </form>";news_tresc_close();
  135.  
  136. news_inne_newsow_close(); } else {
  137.  
  138.  
  139.  
  140.  
  141.  
  142. $komentarze = mysql_query ("SELECT * FROM news_kom WHERE nrnewsa='$id';") or
  143.  
  144. die ("błąd w pytaniu komentarze");
  145.  
  146. $ilekom = mysql_numrows($komentarze);
  147.  
  148.  
  149.  
  150. echo "<p class=\"b\">&nbsp;Komentarze</p><br /><br />&nbsp;Numer newsa: <b>$id</b><br />&nbsp;Komentarzy: <b>$ilekom</b><br /><br /><table border=\"0\" width=\"99%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" class=\"b\">";
  151.  
  152. echo "<a href=\"comments.php?co=dodaj&amp;id=$id\"><b>Skomentuj!</b></a>";
  153.  
  154. if ($ilekom > 0){
  155.  
  156.  
  157.  
  158. while ($rekord = mysql_fetch_array ($komentarze)) {
  159.  
  160. $id = $rekord[0];
  161.  
  162. $text = $rekord[1];
  163.  
  164. $date = $rekord[2];
  165.  
  166. $ip = $rekord[3];
  167.  
  168. $autor = $rekord[4];
  169.  
  170. $nrnewsa = $rekord[5];
  171.  
  172.  
  173.  
  174. $q1 = "SELECT * FROM uzytkownicy WHERE login='$autor'";
  175.  
  176. $r1 = mysql_query ($q1);
  177.  
  178. $row=mysql_fetch_array($r1);
  179.  
  180. $avart = $row['avart'];
  181.  
  182. $id2 = $row['id'];
  183.  
  184. $email_autora = $row['email'];
  185.  
  186. $ggo = $row['gg'];
  187. if($avart<>'') $avart = '<td valign="top" width="70" class="tbl2 style="padding:5px; border-right: #424242 1px solid" align="center">
  188.  
  189. <img src="'.$avart.'" border="1" align="left" width="65" height="65"></td>'; else $avart = '';
  190. if($email_autora<>'') $email_autora = '<a href="mailto:'.$email_autora.'">Email</a>'; else $email_autora = 'Brak';
  191.  
  192. echo '<table cellspacing="1" cellpadding="0" bgcolor="#434343" width="100%">
  193.  
  194. <tr>
  195.  
  196. <td>
  197.  
  198. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  199.  
  200. <tr>
  201.  
  202. <td class="forum-caption">
  203.  
  204. Dodał Komętarz: <b>'.$autor.'</b>
  205.  
  206. </td>
  207.  
  208. <td class="forum-caption" width="30%" align="right">
  209.  
  210. </td>
  211.  
  212. </tr>
  213.  
  214. </table>
  215.  
  216. </td>
  217.  
  218. </tr>
  219.  
  220. <tr>
  221.  
  222. <td class="tbl1">
  223.  
  224. <table cellspacing="0" cellpadding="0" width="100%">
  225.  
  226. <tr>
  227.  
  228. '.$avart.'
  229.  
  230.  
  231.  
  232. <td class="txt" valign="top"><div align="justify">
  233.  
  234. '.$text.'
  235.  
  236. </div></td>
  237.  
  238. </tr>
  239.  
  240. </table>
  241.  
  242.  
  243.  
  244.  
  245.  
  246. <table width="100%" cellspacing="0" cellpadding="0" border="0">
  247.  
  248. <tr>
  249.  
  250. <td colspan="2" height=1></td>
  251.  
  252. </tr>
  253.  
  254. <tr height=20>
  255.  
  256. <td class="tbl2">
  257.  
  258. &nbsp;<a href="profil.php?mode=pokaz&id='.$id2.'">'.$autor.'</a> <font color="#CBCFD2">|</font> <a href="mailto:'.$email_autora.'">Napisz E-maila</a> <font color="#CBCFD2">|</font> GG: '.$ggo.' <font color="#CBCFD2">|</font>
  259.  
  260.  Data: '.$date.' <font color="#CBCFD2">|</font> IP: '.$ip.'
  261.  
  262. </td>
  263.  
  264. </tr>}
  265.  
  266. </table></td></tr><br />';
  267.  
  268. } echo "<br />";
  269.  
  270. }
  271.  
  272.  else {
  273.  
  274.  echo '<table width="99%">';
  275.  
  276. echo "<tr>
  277.  
  278. <td align=\"center\" width=\"100%\" bgcolor=\"#E3E3E3\" class=\"uni_01\"><b><font color=\"black\">Brak komentarzy!</font></b></td>
  279.  
  280. </tr>
  281.  
  282. <tr>
  283.  
  284. <td width=\"100%\" class=\"uni_01\"></td>
  285.  
  286. </tr>
  287.  
  288. <tr>
  289.  
  290. <td width=\"100%\" class=\"uni_01\">Nie znaleziono komentarzy dla newsa o numerze $id.<br /><br /><br /><a href=\"comments.php?co=dodaj&amp;id=$id\"><b>Skomentuj!</b></a></td>
  291.  
  292. </tr>";
  293.  
  294. }
  295.  
  296. echo "</table>";
  297. news_tresc_close();
  298. news_inne_newsow_close();
  299.  
  300. }
  301.  
  302. }
  303.  
  304. }
  305.  
  306.  
  307.  
  308.  
  309.  
  310. //Skora//
  311.  
  312. include ("theme/$theme/index.php");
  313.  
  314. ?>