I have the PHP code that saves all textarea inputs to a text file, except it fuses all consequent messages at the last letter of every input. For instance, if the first textarea content is:
Hello
How are you
Good bye
Then the second textarea content is:
Let me upload this.
Inform me if you receive it.
After submitting both messages, the output text file shows this:
Hello
How are you
Good byeLet me upload this.
Inform me if you receive it.
I need a real help to adjust the PHP file so that it insert a separator (like a horizontal line or *************) at the end of every message with n.
Code:
<?php
$filename = 'posts.txt';
$msg = (isset($_POST['msg']) ? $_POST['msg'] : null);
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)"; exit;
}
if (fwrite($handle, $msg) === FALSE) {
echo "Cannot write to file ($filename)"; exit;
}
echo "Success, wrote ($msg) to file ($filename)"; fclose($handle);
}
else {
echo "The file $filename is not writable";
}
?>
Form:
<form id="post" name="post" action="storeText.php" method="post">
<textarea cols="x" rows="x" name="msg"></textarea>
<input class="button" type="submit" value="POST!"/>
</form>
<div class="menuItem" > <?=$msg?> </div>