Form Data will not post to csv file
Forum rules
PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
MUST READ:
http://www.wysiwygwebbuilder.com/forms.html
http://www.wysiwygwebbuilder.com/form_wizard.html
Frequently Asked Questions about Forms
PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
MUST READ:
http://www.wysiwygwebbuilder.com/forms.html
http://www.wysiwygwebbuilder.com/form_wizard.html
Frequently Asked Questions about Forms
-
-
- Posts: 4
- Joined: Thu Aug 09, 2018 11:37 pm
Form Data will not post to csv file
I will admit to being a novice here, but I have run out of places to troubleshoot, and a search of this site does not reveal anything helpful here (apologies if I missed a topic this is addressed.)
I added a very simple three Editbox form with a Submit button to a new page on an existing site, all built with Wysiwyg.
I used the Form Wizard to set things up, including the addition of a .csv file to record the data entered so that I can retrieve that information and manipulate it in Excel on my personal computer (it will be a registration form eventually.)
The page displays. The edit boxes receive the information. The success page displays. An email is sent out containing the data entered. But nothing goes to the .csv file. Its empty, and stays empty.
I have double and triple checked the read/write permissions of the .csv file and the location was set when the file was created by the Form Wizard, and my hosting site supports PHP (v7.0.33). The page is PHP enabled.
The events "onsubmit:Form Submit:self" and "onsubmit:Form Reset:self" are Form Properties.
These are all just starting points for what I want to do (add) to the form later. But I want to get past this hurdle of why the data is not writing to the .csv before I continue.
Any ideas?
I added a very simple three Editbox form with a Submit button to a new page on an existing site, all built with Wysiwyg.
I used the Form Wizard to set things up, including the addition of a .csv file to record the data entered so that I can retrieve that information and manipulate it in Excel on my personal computer (it will be a registration form eventually.)
The page displays. The edit boxes receive the information. The success page displays. An email is sent out containing the data entered. But nothing goes to the .csv file. Its empty, and stays empty.
I have double and triple checked the read/write permissions of the .csv file and the location was set when the file was created by the Form Wizard, and my hosting site supports PHP (v7.0.33). The page is PHP enabled.
The events "onsubmit:Form Submit:self" and "onsubmit:Form Reset:self" are Form Properties.
These are all just starting points for what I want to do (add) to the form later. But I want to get past this hurdle of why the data is not writing to the .csv before I continue.
Any ideas?
Last edited by gmaclean482 on Thu Feb 27, 2020 3:35 pm, edited 1 time in total.
Re: Form Data will not post to csv file
The only reason I can think why this can fail is when the cvs is not accessible/writable.
Are there any errors in PHP error log on the server?
Are there any errors in PHP error log on the server?
-
-
- Posts: 4
- Joined: Thu Aug 09, 2018 11:37 pm
Re: Form Data will not post to csv file
OK, I will amend my previous post.
IF I turn off the csv file write I get the email (I forgot that I did that last night). Everything in my previous post is based on that configuration, including the display of the success.html file.
When I turn the csv file write on and click "Submit" I get a "can't open file" error.
This is the error I get in the log:
[27-Feb-2020 16:24:41 UTC] PHP Warning: fopen(./public_html/Athlete_Data/formdata.csv): failed to open stream: No such file or directory in /home/churchc1/public_html/TestBed.php on line 59
The page is named "TestBed.php"
Line 59 of the page code is:
$handle = fopen($csvFile, 'a') or die("can't open file");
Earlier in the page code:
$success_url = './Success.html';
$error_url = './Failure.html';
$csvFile = "./formdata.csv";
and again, in the host site directory the csv file is in,
./public_html/Athlete_Data/formdata.csv
and is present, and the file formdata.csv was created via the Form Wizard.
It really seems that the Form Wizard created the file, but instructed the code to look for the .csv file in "testbed.php" rather than in the proper directory. Should I edit the .php file by hand? and will this happen with any other .csv links I create? Also, I note double quotes around the filename reference in the $csvFile = line above, I dont know if that makes a difference.
IF I turn off the csv file write I get the email (I forgot that I did that last night). Everything in my previous post is based on that configuration, including the display of the success.html file.
When I turn the csv file write on and click "Submit" I get a "can't open file" error.
This is the error I get in the log:
[27-Feb-2020 16:24:41 UTC] PHP Warning: fopen(./public_html/Athlete_Data/formdata.csv): failed to open stream: No such file or directory in /home/churchc1/public_html/TestBed.php on line 59
The page is named "TestBed.php"
Line 59 of the page code is:
$handle = fopen($csvFile, 'a') or die("can't open file");
Earlier in the page code:
$success_url = './Success.html';
$error_url = './Failure.html';
$csvFile = "./formdata.csv";
and again, in the host site directory the csv file is in,
./public_html/Athlete_Data/formdata.csv
and is present, and the file formdata.csv was created via the Form Wizard.
It really seems that the Form Wizard created the file, but instructed the code to look for the .csv file in "testbed.php" rather than in the proper directory. Should I edit the .php file by hand? and will this happen with any other .csv links I create? Also, I note double quotes around the filename reference in the $csvFile = line above, I dont know if that makes a difference.
Re: Form Data will not post to csv file
This error indicates that either the file does not exist or the file / folder is not writable.
You do not have to edit the code. If the path is not valid then you can set the correct path in the properties of the form.
You do not have to edit the code. If the path is not valid then you can set the correct path in the properties of the form.
-
-
- Posts: 4
- Joined: Thu Aug 09, 2018 11:37 pm
Re: Form Data will not post to csv file
The file is now correct in the PHP file
$success_url = './Success.html';
$error_url = './Failure.html';
$csvFile = "./public_html/Athlete_Data/formdata.csv";
I have cleared any cached pages to make sure that I am getting the current version, and I still get the "can't open file" error from line 59 (previous post). The error log is as follows:
[27-Feb-2020 18:35:20 UTC] PHP Warning: fopen(./public_html/Athlete_Data/formdata.csv): failed to open stream: No such file or directory in /home/churchc1/public_html/TestBed.php on line 59
It STILL looks like the PHP code is trying to open the right file ./public_html/Athlete_Data/formdata.csv but not looking in the right location /home/churchc1/public_html/TestBed.php
$success_url = './Success.html';
$error_url = './Failure.html';
$csvFile = "./public_html/Athlete_Data/formdata.csv";
I have cleared any cached pages to make sure that I am getting the current version, and I still get the "can't open file" error from line 59 (previous post). The error log is as follows:
[27-Feb-2020 18:35:20 UTC] PHP Warning: fopen(./public_html/Athlete_Data/formdata.csv): failed to open stream: No such file or directory in /home/churchc1/public_html/TestBed.php on line 59
It STILL looks like the PHP code is trying to open the right file ./public_html/Athlete_Data/formdata.csv but not looking in the right location /home/churchc1/public_html/TestBed.php
-
-
- Posts: 4
- Joined: Thu Aug 09, 2018 11:37 pm
Re: Form Data will not post to csv file
OK, another troubleshooting point, should there be anything in the Submit button properties regarding Link:File or URL parameters for internal links?
Re: Form Data will not post to csv file
Either the path in the form properties is incorrect.
or the file does not is the specified folder.
The problem is unrelated to URL parameters.
or the file does not is the specified folder.
The problem is unrelated to URL parameters.
Re: Form Data will not post to csv file
I have a similar problem in saving form data to a csv file
If I upload all my site pages to the public_html dir and create the data file via the form/properties/advanced where the new file is set to ./awwwwdata.csv the file is put into the root dir but data is saved to a file in the public_html dir (if the file is already there). If not, the file is created at run time and data entered
If I create the file as ./public_html then the browser throws up the "can't open file" message. The datafile permissions are set to 0644 or 0666
I can save create a new file any where on my server at design time,
thus /public_html/SQH/awwwwdata.csv is the path and the csv data is created in the correct dir but "can't open file" appears
if I create this file ./SQH/awwwwdata.csv which I can do by having another root subdirectory, then the file is created in ./SQH and data is correctly saved to it
If I upload all my web files to ./SQH/ then again files are created but data writing to then fails irrespected of where the data directory is created.
An easy easly solution to this problem might be to make the file path below the server directory tree editable
Thanks Norman
If I upload all my site pages to the public_html dir and create the data file via the form/properties/advanced where the new file is set to ./awwwwdata.csv the file is put into the root dir but data is saved to a file in the public_html dir (if the file is already there). If not, the file is created at run time and data entered
If I create the file as ./public_html then the browser throws up the "can't open file" message. The datafile permissions are set to 0644 or 0666
I can save create a new file any where on my server at design time,
thus /public_html/SQH/awwwwdata.csv is the path and the csv data is created in the correct dir but "can't open file" appears
if I create this file ./SQH/awwwwdata.csv which I can do by having another root subdirectory, then the file is created in ./SQH and data is correctly saved to it
If I upload all my web files to ./SQH/ then again files are created but data writing to then fails irrespected of where the data directory is created.
An easy easly solution to this problem might be to make the file path below the server directory tree editable
Thanks Norman
Re: Form Data will not post to csv file
If no data is written to the file then either the location of the file is incorrect or the permissions are not valid.
Re: Form Data will not post to csv file
How do I properly set permissions at what level? I have a public_html/website.com/site.html format. Where and how do I set permissions so that I can write to the csv?
Re: Form Data will not post to csv file
You will need to set the permissions of the CVS file on th server. For example, via FileZilla.
Re: Form Data will not post to csv file
Right, but my question would be at what level do I need to do this? IE at the website root folder? website.com, the public_html? And then, what should the setting be so that the form can make changes? I don't think having 777 would be appropriate or safe. Is there another credential somewhere I should have set so that the form can make modifications (making it a user basically)? <--guessing here. 

Re: Form Data will not post to csv file
You can first try 666, if that does not work then use 777.
As long as the file is writable, it's OK.
As long as the file is writable, it's OK.
Re: Form Data will not post to csv file
And where would I apply this to? The file, or does the folder need the setting?
- BaconFries
-
- Posts: 5800
- Joined: Thu Aug 16, 2007 7:32 pm
Re: Form Data will not post to csv file
You apply the permission to the file itself. You also need to ensure the path to the folder / file is correct such as the following public_html/your folder/nameof.csv As Pablo you can use the likes of FileZilla to set this or you can set via the server using cPanel.And where would I apply this to? The file, or does the folder need the setting?
- wwonderfull
-
- Posts: 1539
- Joined: Fri Aug 21, 2020 8:27 am
- Contact:
Re: Form Data will not post to csv file
I do not have any problem with the csv. I still use it. the problem may be that when you go to form advanced and then check on csv it wants you to name a .formdata.csv you save and publish it in public_html or on other cases htdocs ftp directory directly, the csv file name has to be the same as published and can not be in sub folders. if the email comes to you good then be sure that form data also comes for sure.