Web Form - E-mail CSV with User input

Published:
Updated:
I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server.

1st - It creates a temp CSV file that is attached to the e-mail to me with the comma separated inputs.

2nd - If there hasen't been any inputs from that day it make a new CSV file on server or if there has been inputs from that day they are appended to the existing file.
 
After spending tons of time reading up on the subject i made this code script, that will let you get the user input sent to you as a E-mail with a CSV file attachment.



HTML code (user input): index.html
 

PHP code: php-form.php


The PHP code as it is at the moment will make two CSV files.
One that is stored on the server that holds all inputs from that day $fp = fopen("file".date("d-m-y").".csv",'a');
and the one that is e- mailed to the chosen e-mail $FileName = $formdata.date("d-m-y-h:i:s").".csv";

I'm working on getting it to send the inputs in the E-mail message also.

Hope you can use it, modify it etc.
Brian A.

Update!!!
I'm currently testing a new version that also sends the user a message that displays the input in a mail with a table layout, It just lacking a bit of fine tuning, but is looking good.

I bet that many of you that tried to make a web form been battling with malformed char set, that's my last hurdle in one of the mail headers.
0
1,728 Views

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.

Get access with a 7-day free trial.
You Belong in the World's Smartest IT Community