Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP comment box using a txt file
    primarykey
    data
    text
    <p>I need to make a comment box using a txt file or anything else that can be queried passively, without using a database server. As I'm fairly new to PHP programming the first idea was to use a text file. The code in general to accomplish this, as far as I can think of logically would be :</p> <pre><code> &lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;form method = "post"&gt; &lt;textarea name = "txt" cols = "25" rows = "5"&gt; Place your comment here ... &lt;/textarea&gt;&lt;br&gt;&lt;br&gt; &lt;input type = "submit" value = "Submit" onclick = "&lt;?php $com = $_POST["txt"]; $file = fopen("inrg.txt", "a"); fwrite($file, "&lt;br&gt;"); for($i=0; $i &lt;= strlen($com) - 1; $i++) { fwrite($file, $com[$i]); if($i % 37 == 0 &amp;&amp; $i != 0) fwrite($file, "&lt;br/&gt;"); } fwrite($file, "&lt;br&gt;------------------------------------------"); fclose($file); ?&gt;"&gt; &lt;br&gt; &lt;/form&gt; &lt;font face = "Times New Roman"&gt;&lt;b&gt;&lt;p&gt;Textul introdus este: &lt;/p&gt;&lt;/b&gt;&lt;/font&gt; &lt;font face = "Comic Sans MS" color = "red" size = "2" &gt; &lt;?php $file = fopen("inrg.txt", "r"); echo fread($file, filesize("inrg.txt")); fclose($file); ?&gt; &lt;/font&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Nothing fancy yet, and it does needs some improvements on the esthetics side. The thing is after I submit something in the comment box, it shows properly but if I do reload in the web browser, the last posted comment it's posted again as many times as I reload the page. Also if there's a way with PHP to make the initial "Place your comment here ..." disappear </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload