separate csv files for each response...

User 2716615 Photo


Registered User
23 posts

Hello,

When using a manual server set-up does anyone know of a way to get a separate CSV file for each response? (as opposed to appending the single 'form_results.CSV').

Also would there be a way of naming these CSV files to match a field on the form?

I need to match the name of the CSV to my uploaded files (e.g. response1.file, response1.csv).


some background...
I have been using a form with a file upload via S-Drive.
For each response I get an email with the form data and an attached file.
This works great in my workflow as I then have a file (emailsubjectline.jpg) and the metadata (emailsubjectline.txt) which I can use in another program without having to use a database.
I would continue using this method but file uploads are limited to 8Mb in S-Drive and 25Mb in Gmail. Some files will be bigger so I need to set up my own server.

Thanks,
Rob.
User 187934 Photo


Senior Advisor
20,196 posts
Online Now

You should be able to alter the php code or write your own myformname.php to process the data.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2716615 Photo


Registered User
23 posts

Hi Eric,
thanks for answering, I have found your jQuery scripts really helpful elsewhere by the way!

Any ideas where to start? I am more of a tinkerer than a coder so I had a look at the various php files and found in
'Form.cfg.php' these lines...

"save_file" :
{
"filename" : "form-results.csv",
"is_present" : true
},

And in 'datasavecsv.cls.php' I found...

// where to save
$this->output_file = Config::GetInstance()->GetStorageFolder( 3 )
. Config::GetInstance()->GetConfig( 'settings', 'data_settings', $this->cfg_section, 'filename' );

if( ! file_exists( $this->output_file) ) {

return $this->_MakeNew();

So I guess I need to take out the ! file exists and call Makenew() every time? and then in the Makenew function I need to give the file a name - but I can't quite see where it is named. Any guidance would be greatly appreciated!

Thanks
Rob.
User 187934 Photo


Senior Advisor
20,196 posts
Online Now

Let me look at this a little closer. I'm pretty sure I can find a way to make it do what you asking.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2716615 Photo


Registered User
23 posts

:) Thanks Eric, I really appreciate you taking the time to look
User 10077 Photo


Senior Advisor
1,096 posts

The csv file is always named the same. If you rename it after each form submission, then you get different filenames, each with one record. Use a separate thank-you page. In the page, include:

<?php
$old_file_name = '/path/to/name-of-csv-file.csv';
$new_file_name = 'path/to/name-you-want-for-the-file.txt';
rename($old_file_name, $new_file_name);
?>
ASK ME ANYTHING
I provide personalized help for Coffeecup Users including personal or group training for Site Designer, Web Form Builder and more via Zoom.
Email me at support@uscni.org or call 865-687-7698.

Did you know that Web Form Builder can be used for both simple and complicated forms and that it's not limited to the default fonts and buttons? Take a look at a form we developed for WindowTinting.com.
https://forms.windowtinting.com/forms/w … ppingcart/
User 2716615 Photo


Registered User
23 posts

Thanks Brian,

when you say 'separate thank-you page' do you mean I should use redirect to custom HTML as the confirmation setting and put the code in with that HTML? or is there another place for the code?

User 10077 Photo


Senior Advisor
1,096 posts

Rob wrote:
Thanks Brian, when you say 'separate thank-you page' do you mean I should use redirect to custom HTML as the confirmation setting and put the code in with that HTML? or is there another place for the code?

The middle choice: "redirect to another URL"

You mentioned you wanted the file to be named according to a field input. Eric mentioned in another thread that form variables are contained in a SESSION and, therefore, lost to a redirected URL. (I'm going to experiment a little to see if I can find out more.) As a possible solution for now, in the php code prior to renaming the file, you use php to open the csv file, read the data, you get the field value that you want, then rename the file using the data from the field. That would satisfy both your requirements.
ASK ME ANYTHING
I provide personalized help for Coffeecup Users including personal or group training for Site Designer, Web Form Builder and more via Zoom.
Email me at support@uscni.org or call 865-687-7698.

Did you know that Web Form Builder can be used for both simple and complicated forms and that it's not limited to the default fonts and buttons? Take a look at a form we developed for WindowTinting.com.
https://forms.windowtinting.com/forms/w … ppingcart/
User 2716615 Photo


Registered User
23 posts

Thanks Brian,

yes I got it working thanks to your tip but then got stuck with the variable name of the file.

I have...
<?php
$myName = 'mydata'
$old_file_name = '/pathto/csv/form-results.csv';
$new_file_name = '/pathto/csv/'.$myName;
rename($old_file_name, $new_file_name);
?>

which renames the file with whatever is stored in $myName. But I could not see how to pass a variable from elsewhere.

I looked up how to pass variables and - as you said - it seems to require a session - I thought perhaps there was already a set of session variables so I tried $myName = $_SESSION['varname']; but no luck - perhaps I could start a session somewhere? (you can probably tell this is new to me! :) )

Rob.
User 10077 Photo


Senior Advisor
1,096 posts

Note: You are missing a semicolon at the end of the $myName= line.

Eric said in this thread http://www.coffeecup.com/forums/web-form-builder/form-results-when-using-redirect-url-for-confirmation/ that you can alter the session variables to not expire so that you have access to the data in the session. This would probably be the best way.

An alternative is to get the data from the csv file. If you are renaming the csv file with each submit, then there should only be one record. Use php to open the file and read in the data. Explode the data and choose the value that you need for your filename. Close the file. Now you have your variable for the filename.
ASK ME ANYTHING
I provide personalized help for Coffeecup Users including personal or group training for Site Designer, Web Form Builder and more via Zoom.
Email me at support@uscni.org or call 865-687-7698.

Did you know that Web Form Builder can be used for both simple and complicated forms and that it's not limited to the default fonts and buttons? Take a look at a form we developed for WindowTinting.com.
https://forms.windowtinting.com/forms/w … ppingcart/

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.