I was wondering if it's possible to save the contents of a html form into csv format?
I was hoping to use it as an alternative to using a database.
PHP has some built-in functionality to help with this.
as an alternative to using a database
Keep in mind that this isn't a drop-in replacement for an actual database engine. A few things to consider:
Definitely possible. Use $_POST['var']
to get the form variables, and then fwrite
them to a file (with comma delimiters or however you like). Also make sure to validate your input.
Sure
Matter of fact it is very easy and could be achieved with one line (Although I would not reccomend during this in production always validate input and you would also need to append to the file)
file_put_contents("mycsvfile.csv",implode(",", $_POST))
Of course. Take your fields and just put them into a file:
$data = '"'.addslashes($first).'","'.addslashes($second).'"'."
";
file_put_contents('form.csv', $data, FILE_APPEND);
store $_POST with fputcsv