web form data to csv file problem
Posted: Fri Apr 22, 2011 8:08 am
Hello,
I am using a simple snippet of code I found online to take web form data and save it to a csv file. The problem is that the resulting csv file looks like this:
Name,Email
Susan Que,suzyq@gmail.comnAl Sata,al@alsata.comnJohn Public,jp@gmail.comn
instead of this:
Name,Email
Susan Que,suzyq@gmail.com
Al Sata,al@alsata.com
John Public,jp@gmail.com
An "n" appears after the email address in the csv file instead of a new line being started. I see the line in the code, but I don't know why it's there or if something else should be in it's place.
This is the code that adds the data to the csv file:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$fp = fopen(”formdata.txt”, “a”);
$savestring = $name . “,” . $email . “n”;
fwrite($fp, $savestring);
fclose($fp);
echo “<h1>You data has been saved in a text file!</h1>”;
?>
Code comes from: http://www.howtoplaza.com/save-web-form-data-text-file
Any help would be appreciated.
Thanks,
Al
I am using a simple snippet of code I found online to take web form data and save it to a csv file. The problem is that the resulting csv file looks like this:
Name,Email
Susan Que,suzyq@gmail.comnAl Sata,al@alsata.comnJohn Public,jp@gmail.comn
instead of this:
Name,Email
Susan Que,suzyq@gmail.com
Al Sata,al@alsata.com
John Public,jp@gmail.com
An "n" appears after the email address in the csv file instead of a new line being started. I see the line in the code, but I don't know why it's there or if something else should be in it's place.
This is the code that adds the data to the csv file:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$fp = fopen(”formdata.txt”, “a”);
$savestring = $name . “,” . $email . “n”;
fwrite($fp, $savestring);
fclose($fp);
echo “<h1>You data has been saved in a text file!</h1>”;
?>
Code comes from: http://www.howtoplaza.com/save-web-form-data-text-file
Any help would be appreciated.
Thanks,
Al