Hi,

Hope someone can help.

I have a form with several fields in it. One of the fields is a textarea. The user can enter data in this field, including carriage returns etc.,

Once the user clicks on SUBMIT I write the form contents to a text file.

When I read the file, I use FGETS. However the textarea field is now split up into multiple strings, which really messes up the presentation.

How do I keep the contents of the textarea as one BIG LONG string? So I understand I would need to use NL2BR to convert the blank lines with BR, I also have a short piece of code to remove any extra lines and also use TRIM to remove stuff from the end of each line.

But how to join it together and write it as one long string so that it can be read correctly?

Many thanks for any help!

Regards,

Mohamed

<?php //test.php
if(isset($_POST['submit'])){
	$area=$_REQUEST['area'];
	$fd=fopen("test.txt","w+");
	fwrite($fd,$area);
	fclose($fd);
	$file_contents=file_get_contents("test.txt");
	print $file_contents;
}
?>
<html>
<body>
<form method="post" action="test.php">
Enter something: <textarea cols=40 rows=10 name="area"></textarea><br />
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

file_get_contents reads the entire file into a string.
Cheers,
Naveen