Witam. Mam kodzik który edytuje pliki na serwerze. Oto on:
  1. <?php
  2. echo('<form action="" method="post"><table width="800" align="center" bgcolor="#DFEECE" cellpadding="0" cellspacing="0">
  3. <tr>
  4. <th class="header" colspan="2">Zmień treść plików</th>
  5. </tr>
  6. <tr>
  7. <th>Wybierz:</th>
  8. <th><select name="page">'); 
  9. $dir = './';
  10. $fd = opendir($dir);
  11. while($file = readdir($fd)){
  12. if(strpos($file, '.txt')){
  13. echo('<option value="'.$file.'">'.$file.'</option>');
  14. }
  15.  
  16. }
  17. $open = fopen($_POST['page'], 'r');
  18. $tresc = '';
  19. while(!feof($open)){
  20. $str = fgets($open);
  21. $str = str_replace('\n', '<br>', $str);
  22. $tresc .= $str;
  23. }
  24. echo('</select><input type="submit" value="Dalej" name="submit"/></th>
  25. </tr></form>
  26. <tr><form action="" method="post">
  27. <th colspan="2"><input type="hidden" name="page" value="'.$_POST['page'].'" /><textarea cols="50" rows="10" name="tresc">'.$tresc.'</textarea></th>
  28. </tr>
  29. <tr>
  30. <th colspan="2"><input type="submit" value="Zapisz" name="submit"/></th>
  31. </tr>
  32. </form>
  33. </table>');
  34. if($_POST['tresc']){
  35. $open = fopen($_POST['page'], 'w');
  36. $write = fwrite($open, $_POST['tresc']);
  37. if($write){
  38. header("Location: panel.php?page=".$_GET['page']."");
  39. }
  40. }
  41. ?>

Gdy wpisuje kilka lini do formularza i klikam zapisz to robi do połowy a potem sie na jakiś czas zacina. Nie powinno tak być. Jak to poprawić?