Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Odbieranie i zapisywanie plików *.txt
Thymson
post
Post #1





Grupa: Zarejestrowani
Postów: 40
Pomógł: 0
Dołączył: 27.12.2006

Ostrzeżenie: (0%)
-----


Co powinienem zrobić jeżeli chcę:
1. Zrobić formularz (To już umiem (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) )
2. Formularz zapisuje się jako plik *.txt
3. Plik *.txt otwiera się w index.php/index.htm w czytelnej formie
Chodzi o notki takie jak blogu, oczywiście prostrze...
Podsumuję (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)
1. Formularz:
  1. <center><input type="text" name="tytul" value="Tytuł Posta" />
  2. <select name="priorytet">
  3. <option />Normalny
  4. <option />Ogłoszenie
  5. <option />Bardzo ważne ogłoszenie
  6. <textarea name="tresc">Treść Posta</textarea>
  7. <input type="submit" value="wyślij">

2. Wysyła się do pliku *.txt
3. "Odbiera go" strona index.htm/index.php
(?)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Thymson
post
Post #2





Grupa: Zarejestrowani
Postów: 40
Pomógł: 0
Dołączył: 27.12.2006

Ostrzeżenie: (0%)
-----


Jeszcze nie sprawdziłem, ale ufam, że działa, na prawdę wielki dzięki, mogę to zastosować też do "możliwości komentowania mojej strony" (?)...

Hmm... Pliki *.txt się wcale nie zapisują :/, nic nie rozumiem, próbuję właśnie "skonfigurować pod siebię" skrypt
"fwrite"..., bo w sumie mi nie zależy, żeby się zapisywal plik, tylko żeby mieć system newsów... Najprostrza wersja mnie interesuje...

Mam tutaj taki skrypcik (nazwa - "Komentarze txt"
  1. <html>
  2. <head>
  3. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2">
  4. </head>
  5. <body>
  6. <?
  7. /*
  8.  
  9. annotate.php3 
  10.  
  11. This is a module that can be placed on any php3 page to allow users to add
  12. their comments. The comments are stored in a file in the current directory,
  13. whose name is constructed by adding ".comment" to the calling page's name,
  14. and merged into the calling page dynamically. (The calling page is not
  15. modified.)
  16.  
  17. I wrote this because I wanted a simple way to add this functionality to my
  18. pages without requiring that mySQL be available.
  19.  
  20. In the message input, blank lines are converted to paragraph tags. No other
  21. conversions are applied. If you don't want your users to be able to input
  22. html, uncomment the "strip_tags" line.
  23.  
  24. Note that the directory must be writable by the web server.
  25.  
  26. Put this module in some convenient location and then embed it in your pages
  27. like so:
  28.  
  29. require("/some/full/path/annotate.php3");
  30. or, relative to the docroot:
  31. require($DOCUMENT_ROOT . "/relativepath/php3");
  32.  
  33. Steve Yelvington <steve@yelvington.com>
  34.  
  35. */
  36. if ($message)
  37. {
  38. /* uncomment the next two lines to strip out html from input */
  39. /* $name = strip_tags($name); */
  40. /* $message = strip_tags($message); */
  41. $message = ereg_replace("rnrn", "n<P>", $message);
  42. $date = date("l, F j Y, h:i a");
  43. $message = "<B>$name </B> -- $date<P> $message <BR><HR>";
  44. $fp = fopen (basename($PHP_SELF) . ".comment", "a");
  45. fwrite ($fp, $message);
  46. fclose ($fp);
  47. }
  48. @readfile(basename(($PHP_SELF . ".comment")));
  49. ?>
  50. <FORM method="post">
  51. <b>Your name:</b><BR><INPUT name="name" type="text" size="55"><BR>
  52. <b>Your comment:</b><BR><TEXTAREA name="message" rows=10 cols=55 wrap=virtual>
  53. </TEXTAREA><BR>
  54. <INPUT name="submit" type="submit" value="Post your comment">
  55. </FORM>
  56. </body>
  57. </html>

Jest coś nie tak z skryptem, bo wcale mi nie działa :/ (?)

Ten post edytował Thymson 27.12.2006, 19:12:54
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 17.10.2025 - 23:13