I have a form on my website meant to collect comments from a user. Once submitted the form data is saved to a csv file using this script
[php]<?php
$mm = $_POST['mm'];
$dd = $_POST['dd'];
$yy = $_POST['yy'];
$name = $_POST['name'];
$comment = $_POST['comment'];
$lines = file('datafeed/filetoread.csv');
$fp = fopen("datafeed/filetoread.csv", "w+");
$header = array_shift($lines);
$savestring = $header . $mm . " " . $dd . " " . $yy . " " . $name . " " . $comment . "\r\n";
fwrite($fp, stripslashes($savestring));
foreach($lines as $line) fwrite($fp, "$line");
fclose($fp);
echo "<h1>Your data has been saved</h1>";
?>
[/php]
I have another page on my site that reads the csv and displays the information using this script
[php]<?php
//create table with header and column names
print(’
Testimonials |
'.$comment.' |
'.$name.' |
?>[/php]
The problem I am having is that whenever a user submits a comment with more than one paragraph the second paragraph doesn’t appear when the csv is read by the second webpage. When I check the csv the 2nd paragraphs information is written on a new line. I need to figure out how to support paragraphs either in the writing of the information to the csv or in the reading of the file.
Any help is greatly appreciated