Collecting user data from HTML form and exporting to Excel

Talk about your favorite PC games, Steam and building awesome custom rigs!

Moderator: Moderators

Post Reply
User avatar
khaag
Senior Member
Posts: 2259
Joined: Sat Mar 18, 2006 7:54 pm
Location: C eh N eh D eh
Contact:

Collecting user data from HTML form and exporting to Excel

Post by khaag » Tue Nov 04, 2008 10:54 pm

How would I go about doing this? Here's the application it's going to be used for. There is a computer set up at a business for the sole purpose of collecting customer's data; kind of like a high-tech address book.

An HTML file is loaded in the browser and has an HTML form in it for the customer to enter his/her name, address, email, etc.

What I want it to do, is when the customer clicks "submit" it will compile the information to a .XLS (excel document) in the background and save it to a specified folder on the hard-drive, while on screen it shows a new HTML page saying Thank You.

Anyone know how I could set this up?

User avatar
bicostp
Moderator
Posts: 10491
Joined: Mon Mar 07, 2005 5:47 pm
Steam ID: bicostp
Location: Spamalot
Contact:

Post by bicostp » Wed Nov 05, 2008 7:57 am

Use a real database instead of a spreadsheet?

I know you can do this with an Access file (it's actually an option in phpbb 2), but using a flat file is a really bad way to store information, especially if you see yourself getting any kind of traffic on your interface.

With a MySQL database, you can quickly spit out a PHP submit form, then another page for you to work with the database on. If you really have to have all your data in Excel (why?), you can make it dump the database contents to a .csv file, which Excel can easily import.

User avatar
khaag
Senior Member
Posts: 2259
Joined: Sat Mar 18, 2006 7:54 pm
Location: C eh N eh D eh
Contact:

Post by khaag » Wed Nov 05, 2008 8:01 am

Um, okay. So could you give me some tips as to how to go about it? :wink:

vb_master
Moderator
Posts: 4793
Joined: Tue Jun 08, 2004 9:52 pm

Post by vb_master » Sun Dec 07, 2008 9:43 pm

khaag wrote:Um, okay. So could you give me some tips as to how to go about it? :wink:
I realize no one has posted in this topic for over a month but I feel sorry for you.

Basically you are going to need a MySQL database, and a PHP page with the form elements you need, and a table in the database with the row names and such set up.

When you want to export the MySQL database, you can use a PHP PEAR plugin that supports writing .XLS files, and then you will be able to dynamically generate a new .XLS file off the server.

I recently used an implementation of something similar to this so I can catalog what is on each DVD I have in a spindle.

If you need any help feel free to PM me.

User avatar
Fenrir
Posts: 14
Joined: Wed Aug 27, 2008 9:20 am

Post by Fenrir » Mon Dec 15, 2008 3:05 am

Howdy. I would've dropped in and provided some advice, but I haven't toured these parts in a while.

I guess what you're talking about doing has many, many possible solutions, and which avenue you choose depends on what you have available to you, and what sorts of technologies you feel comfortable getting involved with. I mean, if it were me, I'd go Glassfish and MySQL, but I'm predominantly a Java programmer. >_>

Firstly, the MySQL database suggestion made by the others here is a good one. MySQL is a well-established database solution that's popular with small organizations and the like, but scales to the needs of large businesses pretty well too. You could probably learn the SQL scripts for Create, Select, Insert, Update, Delete and Drop operations within an hour or so. And better yet, it's free. :D

But what's going to process the data from this HTML form you're talking about, and put it in the database? (or into XLS files, if you still want those)
Well, the neatest solution is to utilize the behaviour the HTML form was designed for, by specifying the method attribute as "post", and the action attribute as a server-side process that's been written to process the form's data. And if you're planning on keeping this all on the one computer, that means installing a web server on the computer and referring to it as "http://localhost/".

So, servers? I know two options quite well, PHP/Apache and Java/Glassfish, both ofwhich have very good MySQL support. If you have experience with Java, you might want to try the Glassfish option, but otherwise, I strongly suggest PHP/Apache. If you don't know PHP, you'll have to learn it - but it's a hell of a lot easier than Java. Installing the server is easy, just install XAMPP, put your written PHP file in the xampp/htdocs folder, and reference it at http://localhost/ (eg. xampp/htdocs/helloworld.php would be executed by typing http://localhost/helloworld.php into the address bar in a web browser on the machine you install the server on).

Actually, if you're really set on churning out XLS files, you could learn ASP or ASP.NET instead. I never did learn much about Microsoft's server-side offerings myself, but as the ASP family of server-side scripting tech comes from Microsoft themselves, they're bound to make working with .XLS files and the like a fair bit friendlier. I could go digging for info on this if it appeals to you, but you'd have to be really insistent on XLS for this.

There's also the faint possibility of not involving a server - I don't recommend it, but there are other ways to scrape the data from the form and feed it to an application outside the web browser. You could embed a Java applet or Flash file into the webpage, have Javascript short-circuit the submit event of the form, and use Javascript to feed info to the Java applet or whatever.
I've never done this, mind, and really wouldn't recommend it.

Let me know what appeals to you, I can get more specific about it if you want.

bobbypig
Posts: 6
Joined: Sun Sep 06, 2009 10:04 am

Re: Collecting user data from HTML form and exporting to Excel

Post by bobbypig » Sun Sep 06, 2009 10:12 am

If you want to construct a database, you should really buy a book as there's no way to fit a guide to php and mysql into a forum post.

also, (I'm not sure if this will work) if you want to stick with the excel idea, php can write text files and you can (most likely, as I don't have access to excel now) import them with minimal clicking/typing

Post Reply