Hi all,
I am trying to get a simple code to work. It will be an text box for users to post a joke, and then append the file "testfile.txt (see below)
It works just fine, but the problem is, the text submitted is just added to the file (with no line break / carriage return ) The results when viewing the file "testfile.txt" is everything runs together.
I want to add the textbox input, as a new paragraph, in the file testfile.txt
I have tried adding \n and \r everywhere, and the script crashes.
Can anyone help (my short php code below )
<?php //test.php
if(isset($_POST['submit'])){
$area=$_REQUEST['area'];
$fd=fopen("testfile.txt","a+");
fwrite($fd,$area);
fclose($fd);
$file_contents=file_get_contents("testfile.txt");
}
?>
<html>
<body>
<center>
Enter your joke below<p>
<form method="post" action="trythis2.php">
<textarea cols=40 rows=10 name="area"></textarea><br />
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
=== Thanks in advance == RickinPV