Witam.
Mam problem z kodem php.
mam dwa pliki zapisane na stronie:
dane.php i ksiega.php
wrzucając oba na stronę mam tabelkę i wpisy z tym iż jedno nad drugim. Niżej na zdjęciach przedstawiam problem:

  1. <?php
  2. define('WPISY', './wpisy.txt');
  3.  
  4. function dodajWpis($tytul, $autor, $www, $tresc)
  5. {
  6. // Ucinanie bialych znakow
  7. $tytul = trim($tytul);
  8. $autor = trim($autor);
  9. $www = trim($www);
  10. $tresc = trim($tresc);
  11.  
  12. // Kontrola danych
  13.  
  14. if(strlen($tytul) < 3)
  15. {
  16. return false;
  17. }
  18.  
  19. if(strlen($autor) < 3)
  20. {
  21. return false;
  22. }
  23.  
  24. if(strlen($tresc) < 10)
  25. {
  26. return false;
  27. }
  28.  
  29. if(strlen($www) > 0)
  30. {
  31. // Jesli adres nie zaczyna sie od http:// to dodaj to
  32. if(strpos($www, 'http://') !== 0)
  33. {
  34. $www = 'http://'.$www;
  35. }
  36. }
  37.  
  38. // Dodawanie
  39.  
  40. $f = fopen(WPISY, 'a');
  41.  
  42. $dane = array(0 =>
  43. time(),
  44. );
  45.  
  46. fwrite($f, implode('|', $dane)."\r\n");
  47. fclose($f);
  48. return true;
  49. } // end dodajWpis();
  50.  
  51. function pobierzWpisy()
  52. {
  53. $wpisy = array_reverse(file(WPISY));
  54.  
  55. $i = 1;
  56. $rezultat = array();
  57.  
  58. foreach($wpisy as $wpis)
  59. {
  60. $wpis = explode('|', trim($wpis));
  61.  
  62. $rezultat[] = array(
  63. 'id' => $i,
  64. 'tytul' => base64_decode($wpis[0]),
  65. 'autor' => base64_decode($wpis[1]),
  66. 'data' => date('d.m.Y, H:i', $wpis[2]),
  67. 'www' => base64_decode($wpis[3]),
  68. 'tresc' => base64_decode($wpis[4])
  69. );
  70. $i++;
  71. }
  72. return $rezultat;
  73. } // end pobierzWpisy();
  74.  
  75. ?>
plik dane.php
  1. <!DOCTYPE html
  2. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  5. <head>
  6. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  7. <link rel="stylesheet" type="text/css" href="style.css" />
  8. <link rel="Shortcut icon" href="favicon.ico" />
  9. <style type="text/css"></style>
  10. <meta name="Robots" content="index, nofollow" />
  11. <meta name="Author" content="Arni" />
  12. <meta http-equiv="Refresh" content="600" />
  13. <meta name="Description" content="Strona poswiecona grze Guild Wars 2" />
  14. <meta name="Keywords" content="Guild Wars 2, GuildWars 2, Guild Wars2, GuildWars2, guild wars 2, guildwars2, guild wars2, guildwars 2, Guild, guild, Wars, wars, 2, Guild Wars, guild wars, GuildWars, guildwars," />
  15. <title>Guild Wars 2</title>
  16. <style type="text/css">
  17. /* <![CDATA[ */
  18. a { text-decoration: none }
  19. a:hover { color: red }
  20. /* ]]> */
  21. </style>
  22. </head>
  23. <body vlink="#0000CC">
  24.  
  25. <!--księga go?ci-->
  26. <a href="ksiega.html" style="position: fixed; margin: 500px 0px 0px 100px;"><img src="image/ksiegagosci.gif"></img>
  27.  
  28. <!--logo-->
  29. <div id="logo"><a href="index.html"><img src="image/logo.png"></a></div>
  30.  
  31. <!---menu nawigacyjne-->
  32. <div id="menu"> <a href="index.html" class="stronaglowna">
  33. <a href="regulamin.html" class="regulamin">
  34. <a href="forum.html" class="forum">
  35. <a href="newsy.html" class="newsy">
  36. <a href="gw2.html" class="gw2">
  37. </a></div>
  38.  
  39. <!--tresc strony-->
  40. <div class="ksiega">
  41. <!---odczyt wpisu--->
  42. <div class="ksiegatext">
  43. <!---Je?li przekracza wymiary należy dodać scrypt java--->
  44. <!---Treść--->
  45.  
  46.  
  47. </div>
  48. <!---wpisy--->
  49. <div class="ksiegawpis">
  50. <!---teść--->
  51.  
  52. <?php
  53.  
  54. require('./dane.php');
  55.  
  56. if($_SERVER['REQUEST_METHOD'] == 'POST')
  57. {
  58. // Dodawanie wpisu
  59. if(dodajWpis($_POST['tytul'], $_POST['autor'], $_POST['www'], $_POST['tresc']))
  60. {
  61. echo '<p>Dziękujemy, wpis został dodany prawidłowo.</p>';
  62. }
  63. else
  64. {
  65. echo '<p>Proszę wypełnić prawidłowo formularz.</p>';
  66. }
  67. echo '<p><a href="ksiega.php">Powrót</a></p>';
  68. }
  69.  
  70. else
  71. {
  72. // Wyświetlanie wpisów
  73. $wpisy = pobierzWpisy();
  74.  
  75. foreach($wpisy as $wpis)
  76. {
  77. echo '<hr /><p><b>Tytuł: <i>'.$wpis['tytul'].'</i>;
  78. Autor: '.$wpis['autor'].'; Data: '.$wpis['data'];
  79. if(strlen($wpis['www']) > 0)
  80. {
  81. echo '; <a href="'.$wpis['www'].'" target="_blank">Strona WWW</a>';
  82. }
  83. echo '</b></p>';
  84. echo '<p>'.$wpis['tresc'].'</p>';
  85. }
  86.  
  87. ?><hr />
  88.  
  89. <form method="post" action="ksiega.php">
  90. <table border="0" width="50%">
  91. <tr>
  92. <td>Tytuł</td>
  93. <td><input type="text" name="tytul"/></td>
  94. </tr>
  95. <tr>
  96. <td>Autor</td>
  97. <td><input type="text" name="autor"/></td>
  98. </tr>
  99. <tr>
  100. <td>WWW</td>
  101. <td><input type="text" name="www"/></td>
  102. </tr>
  103. <tr>
  104. <td>Treść</td>
  105. <td><textarea name="tresc" rows="4" cols="50"></textarea></td>
  106. </tr>
  107. <tr>
  108. <td></td>
  109. <td><input type="submit" value="Dodaj"/></td>
  110. </tr>
  111. </table>
  112. </form>
  113. <?php
  114.  
  115. }
  116.  
  117. ?>
  118. </div>
  119.  
  120. </div>
  121.  
  122. </body>
  123. </html>
ksiega.php

Gdy zmieniam php w ksiega.php, wpisy mam wyświetlane z lewej strony, ale wtedy nie ma tabelek dodających wpis, niżej obrazek:


Tutaj dodaję plik po zmianie php.
Przepraszam że jeden pod drugim, nie zmieściło mi się wszystko w pierwszym poście.

  1. <!DOCTYPE html
  2. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  5. <head>
  6. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  7. <link rel="stylesheet" type="text/css" href="style.css" />
  8. <link rel="Shortcut icon" href="favicon.ico" />
  9. <style type="text/css"></style>
  10. <meta name="Robots" content="index, nofollow" />
  11. <meta name="Author" content="Arni" />
  12. <meta http-equiv="Refresh" content="600" />
  13. <meta name="Description" content="Strona poswiecona grze Guild Wars 2" />
  14. <meta name="Keywords" content="Guild Wars 2, GuildWars 2, Guild Wars2, GuildWars2, guild wars 2, guildwars2, guild wars2, guildwars 2, Guild, guild, Wars, wars, 2, Guild Wars, guild wars, GuildWars, guildwars," />
  15. <title>Guild Wars 2</title>
  16. <style type="text/css">
  17. /* <![CDATA[ */
  18. a { text-decoration: none }
  19. a:hover { color: red }
  20. /* ]]> */
  21. </style>
  22. </head>
  23. <body vlink="#0000CC">
  24.  
  25. <!--księga go?ci-->
  26. <a href="ksiega.html" style="position: fixed; margin: 500px 0px 0px 100px;"><img src="image/ksiegagosci.gif"></img>
  27.  
  28. <!--logo-->
  29. <div id="logo"><a href="index.html"><img src="image/logo.png"></a></div>
  30.  
  31. <!---menu nawigacyjne-->
  32. <div id="menu"> <a href="index.html" class="stronaglowna">
  33. <a href="regulamin.html" class="regulamin">
  34. <a href="forum.html" class="forum">
  35. <a href="newsy.html" class="newsy">
  36. <a href="gw2.html" class="gw2">
  37. </a></div>
  38.  
  39. <!--tresc strony-->
  40. <div class="ksiega">
  41. <!---odczyt wpisu--->
  42. <div class="ksiegatext">
  43. <!---Je?li przekracza wymiary należy dodać scrypt java--->
  44. <!---Treść--->
  45. <?php
  46. // Wyświetlanie wpisów
  47. require('./dane.php');
  48. $wpisy = pobierzWpisy();
  49.  
  50. foreach($wpisy as $wpis)
  51. {
  52. echo '<hr /><p><b>Tytuł: <i>'.$wpis['tytul'].'</i>;
  53. Autor: '.$wpis['autor'].'; Data: '.$wpis['data'];
  54. if(strlen($wpis['www']) > 0)
  55. {
  56. echo '; <a href="'.$wpis['www'].'" target="_blank">Strona WWW</a>';
  57. }
  58. echo '</b></p>';
  59. echo '<p>'.$wpis['tresc'].'</p>';
  60. }
  61.  
  62. ?>
  63.  
  64. </div>
  65. <!---wpisy--->
  66. <div class="ksiegawpis">
  67. <!---teść--->
  68.  
  69. <?php
  70.  
  71. require('./dane.php');
  72.  
  73. if($_SERVER['REQUEST_METHOD'] == 'POST')
  74. {
  75. // Dodawanie wpisu
  76. if(dodajWpis($_POST['tytul'], $_POST['autor'], $_POST['www'], $_POST['tresc']))
  77. {
  78. echo '<p>Dziękujemy, wpis został dodany prawidłowo.</p>';
  79. }
  80. else
  81. {
  82. echo '<p>Proszę wypełnić prawidłowo formularz.</p>';
  83. }
  84. echo '<p><a href="ksiega.php">Powrót</a></p>';
  85. }
  86.  
  87. else
  88. {
  89.  
  90.  
  91. ?>
  92. <hr />
  93.  
  94. <form method="post" action="ksiega.php">
  95. <table border="0" width="50%">
  96. <tr>
  97. <td>Tytuł</td>
  98. <td><input type="text" name="tytul"/></td>
  99. </tr>
  100. <tr>
  101. <td>Autor</td>
  102. <td><input type="text" name="autor"/></td>
  103. </tr>
  104. <tr>
  105. <td>WWW</td>
  106. <td><input type="text" name="www"/></td>
  107. </tr>
  108. <tr>
  109. <td>Treść</td>
  110. <td><textarea name="tresc" rows="4" cols="50"></textarea></td>
  111. </tr>
  112. <tr>
  113. <td></td>
  114. <td><input type="submit" value="Dodaj"/></td>
  115. </tr>
  116. </table>
  117. </form>
  118. <?php
  119.  
  120. }
  121.  
  122. ?>
  123. </div>
  124.  
  125. </div>
  126.  
  127. </body>
  128. </html>


Rozwiązałem ten problem rozbijając plik dane.php na dwa pliki dodający wpisy i odczytujący.
Pozdrawiam