Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When we attempt to extract data submitted online via a Web-Form and to write the same to a text file which is placed on the web-server -- without overwriting the information already contained in the said text file, then we use the following code within the tags:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;form action="" method=""&gt; &lt;input value="submit"&gt; &lt;div&gt;Name: &lt;input value=""&gt;&lt;/div&gt; &lt;div&gt;email: &lt;input value=""&gt;&lt;/div&gt; ... ... ... &lt;div&gt;&lt;button&gt;Submit&lt;/button&gt;&lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The above HTML Code is coupled with the following PHP Code:</p> <pre><code>&lt;?php $fileName = 'fdata.txt'; $fp = fopen('fdata.txt', 'a'); $savestring = $_POST['name'] . ',' . $_POST['email'] ; fwrite($fp, $savestring); fclose($fp); ?&gt; </code></pre> <p>But the above two Codes together lead to data that is appended and stringed together in the text file -- that is to say, every new record (set of data) extracted from subsequent Web-Forms does not begin at a new line (there is no line-break or carriage-return).</p> <p>I searched the Net for a Solution to the above Issue -- as suggested on the Net, I added “\r\n” (in double quotes) and also used ‘PHP_EOL’ (without quotes) as under:</p> <pre><code>$fp = fopen('fdata.txt', 'a', "\r\n"); $savestring = “\r\n” . PHP_EOL . ' ' . $_POST['name'] . ',' . $_POST['email'] . PHP_EOL; </code></pre> <p>Yet there was no line-break at all (my web-server and my desktop use Windows). It means that there was no practicable Solution within the knowledge of anyone of the millions of Users of Net in the World. It appears that the parameter ‘a’ overrides “\r\n”, ‘PHP_EOL’ etc.</p>
 

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