| Coding Forum Problems with your code? Let's hear about it. |
10-15-2003, 07:24 PM
|
#1 (permalink)
|
|
Inactive
Join Date: 10-15-03
Posts: 4
Latest Blog: None
|
Formmail data to a .CSV file
Hello,
I need to construct a formmail page where my users will fill in the blanks, select from pull downs, radios, etc... and have all of that sent to me in a comma seperated file. Can anybody recommend a script to me? An added bonus would be if the script could be configured such that a user could make entry after entry (example, they will be entering in names, addresses and phone numbers... and if they have 12 to do in one sitting...) and then submit the entire lot at once, with one CSV file.
I may have to take this in 2 steps if that second part is a huge deal... but at least I need the form results to be either sent to me or stored on the server in a .CSV file. Any thoughts??
Eric
|
|
|
10-16-2003, 06:48 AM
|
#2 (permalink)
|
|
Administrator
Join Date: 10-13-03
Location: Virginia
Posts: 2,073
Latest Blog: None
|
This is what I would suggest.
A webform that had a mysql database backend. Users submitted data via the form and the data was entered into the mysql database for storage.
Another webscript could be constructed to basicly export the mysql database in CSV format or you could then use phpmyadmin (a php based mysql interface) to export the database in CSV format.
|
|
|
10-16-2003, 07:41 AM
|
#3 (permalink)
|
|
Inactive
Join Date: 10-15-03
Posts: 4
Latest Blog: None
|
Hmm... I"d like to stay away from mysql and php if possible, not because I think they are bad, but just because they are beyond my understanding right now. There is no need for this to be stored in a database, once the data has been presented to me, there is no need for it to linger. I'm simply looking for a way to get the data to me in a format that I can use in a spreadsheet. Right now, I have to take the form results and copy/paste each field into an excell file. I'm trying to eliminate the hand-work, as we expect the volume of forms processed to increase greatly.
|
|
|
10-16-2003, 08:04 AM
|
#4 (permalink)
|
|
Administrator
Join Date: 10-13-03
Location: Virginia
Posts: 2,073
Latest Blog: None
|
Quote:
|
I'm trying to eliminate the hand-work, as we expect the volume of forms processed to increase greatly.
|
That is the exact reason to automate the process. If you have the webform e-mail you every time the form is filled out and you have a lot of these forms getting filled out your day is going to end up being fill with just inserting these into the spreedsheet.
You could design the form to write the results to a text file on the server and then go in say once a day or once a week or something and download the text file and bulk process them that way.
I was imitated with php and mysql before I learned myself. One day I decided I needed to code a custom script so I got myself a few mysql books and a few php books and taught myself.
You said your entering it into a spreadsheet so the data is lingering on in some manor. Is there a reason your putting it into excel? Are you taking the info and making charts out of it or doing calculations based upon teh info? Or is excel just a storage medium?
|
|
|
10-16-2003, 08:28 AM
|
#5 (permalink)
|
|
Inactive
Join Date: 10-15-03
Posts: 4
Latest Blog: None
|
The data collected in processed through our MIS system and used for mailing stuff. In simplified terms, a user enters their name, address, zip, and chooses some options from pull down menus.
the CSV file I need in the end, has all these entries in seperate fields. our MIS system process that, calculates zip+4 for mailing, and use those selected "options" from the pull downs to tell our software which version of a particular postcard that person needs to receive.
Hmmm... maybe I DO need to give the mysql thing a shot. I know my servers support it, would you recommend myphpadmin to run it? I know I can install that pretty easy as well.
What books have you read that you might recomend to me?
|
|
|
10-16-2003, 08:34 AM
|
#6 (permalink)
|
|
Administrator
Join Date: 10-13-03
Location: Virginia
Posts: 2,073
Latest Blog: None
|
phpmyadmin is basicly a backdoor web based interface to mysql. You can use it to create a database and to setup the tables and fields. You can then use it to manipulate the data to some extent as well as to export the data in any number of methods.
I cant list the books I used right now as I dont recall the titles. WHen I get home ill try to remember to look them up.
|
|
|
10-16-2003, 02:01 PM
|
#7 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
You can use JavaScript to format the data into CSV if CSV is just text.
Then the simple PHP script can either write it to a file on the server, or paste it into an email and send it to you.
Your server will have to either have a folder with read write and execute access for the script, or access to a mail sender, emails can usually be sent with the mail() function in PHP as long as the server owner has not turned it off.
|
|
|
10-16-2003, 03:07 PM
|
#8 (permalink)
|
|
Administrator
Join Date: 10-13-03
Location: Virginia
Posts: 2,073
Latest Blog: None
|
Ok the books I used to learn where entitled
MySQL by Paul DuBois
Teach Yourself PHP4 in 24 Hours Sams Publishing
PHP and MySQL in Web Development
I had a few others but those where the main reference materials
|
|
|
10-20-2003, 11:36 AM
|
#9 (permalink)
|
|
Inactive
Join Date: 10-20-03
Posts: 21
Latest Blog: None
|
The best way in my opinion is what lazyjim said, though personally I would format it into the comma deliminated string using PHP, but if you want to limit your learning curve doing the formating with javascript would work as well.
Spend a few moments and go to php.net, best learning resource for PHP and its free. Specifically take a look at:
http://ca2.php.net/manual/en/function.fopen.php
fopen() is very easy to use and there are lot of examples there on the page, I use fopen() and its more complext partner fsockopen() probably more than anything else, well worth the time to check it out.
Cul
|
|
|
10-20-2003, 09:09 PM
|
#10 (permalink)
|
|
Inactive
Join Date: 10-13-03
Posts: 4
Latest Blog: None
|
I'm not sure how to export form data to a mysql database, but once you figure that out, I've found a tutorial to export your data from the database to an Excel file. It's very easy and short. Just go to this URL.
http://www.phpfreaks.com/tutorials/114/0.php
|
|
|
10-21-2003, 03:09 AM
|
#11 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
Culland, thanks for you input, and I agree it would be a better learning experience to do it all with PHP.
However, formatting the data into plain-text with the comma's/tabs/crlf or whatever .csv uses on the client side will save the server from some processing. This is a form of disributed computing. But may not be important in this particular case.
The dissadvantage of useng JavaScript, is that not everyone has it turned on or even available in their browsers.
|
|
|
10-21-2003, 09:15 AM
|
#12 (permalink)
|
|
Inactive
Join Date: 10-20-03
Posts: 21
Latest Blog: None
|
Agreed! I think I am a bit to server intensive in my code cause I get tired of getting something to work and then finding it wont work in one browser type or as you said someone comes along with javascript disabled, which according to the stats is like 13% of browsers on the web from the stat I saw the other day.
It however is good to be reminded that not everything has to be done server side
Cul
|
|
|
10-22-2003, 11:25 AM
|
#13 (permalink)
|
|
Inactive
Join Date: 10-13-03
Posts: 4
Latest Blog: None
|
I use phpMyAdmin for some of my database stuff and I just found that there is an option to export a table in .csv format. This should help once you get the data into the database and need to export it to excel
|
|
|
10-22-2003, 12:42 PM
|
#14 (permalink)
|
|
Administrator
Join Date: 10-13-03
Location: Virginia
Posts: 2,073
Latest Blog: None
|
To use the command line interface to export the database to a CSV file try this.
[code:1:8dea7bc730]mysqldump -u (username) -p (password) -T (directory_to_place_output) --fields-terminated-by=',' (db_name) (table_name)[/code:1:8dea7bc730]
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 06:55 PM.
© Copyright 2008 V7 Inc
|