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,[email protected] Sata,[email protected] Public,[email protected]
instead of this:
Name,Email
Susan Que,[email protected]
Al Sata,[email protected]
John Public,[email protected]
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 “You data has been saved in a text file!
”; ?>Code comes from: http://www.howtoplaza.com/save-web-form-data-text-file
Btw, if someone can also tell me how to have the csv file (formdata.txt) sent to me by email everytime it’s updated with new data, that would be appreciated as well.
Thanks,
Al