On Jun 16, 5:59 am, st...@ipv6canada.com (Steve Bertrand) wrote: > On 2010.06.16 07:12, Shlomi Fish wrote: > > > > > > > On Wednesday 16 Jun 2010 01:58:19 Herb wrote: > >> My goal is to create a form that has multiple pages with a few > >> questions per page so that visitors aren’t dropped into a large single > >> page form that they feel is too daunting and therefore don’t fill it > >> out. I would like the form to write to a mysql database and I’ve read > >> that gathering the information via multiple pages would be done with > >> ‘hidden fields’. > > >> Is it best to create multiple HTML pages containing hidden fields with > >> the last pages’ action submitting to the cgi script, or is it fine to > >> create one cgi script for the entire process? > > > I've always done it with hidden fields, which allows the final form > > submission > > to be done atomically. It is possible that web-development frameworks such > > as > > Catalyst (see: > >http://www.catalystframework.org/) provide elegant abstractions above it, > > but I never investigated. > > I always used to use one CGI script that also contained the HTML code. > I'd have a 'do' param that would essentially guide the script into the > next subroutine. > > For MySQL, I'd use DBI. > > Things have changed a bit. Now I use CGI::Application along with > DBIx::Class. > > A current project I'm working on uses this setup. The CGI portion of the > application is simply a GUI front-end 'plugin' for an otherwise > CLI-oriented system. > > The primary cgi script simply bootstraps itself, does the session work, > then passes off all responsibility to the backend modules. The gui > module itself contains some 50+ subs and 2700 lines of code. All of the > HTML is handled by HTML::Template, so the code is absolutely 100% > separate from the HTML (Literally... there is not a single HTML element > or text anywhere in the code). > > CGI::Application has numerous handy plugins which further ease coding. > > DBIx::Class is a tremendously handy piece of software for db > interaction, and I'll likely never use anything else again for the task. > > All three combined allow code to be written in a straight-forward and > easy-to-understand reusable-type fashion. The template system allows you > to throw simple scalars, up to complex Perl data structures at it (aref > of hrefs that contain arefs of hrefs) directly for looping, instead of > declaring each and every form variable individually. > > The learning curve is higher than just writing CGI-type code, but I > assure you that it is well, well worth doing it in a scalable manner > like this from the beginning. > > In my current case, the cgi/gui portion is simply a front-end that takes > input, and displays output of a much larger system that contains > numerous other modules that actually do the work. With that said, I can > see how using a setup like this even for a small project would be well > worth the time that is needed to invest into learning more. > > Automation becomes a piece of cake. The following modules contain > exceptionally good documentation, specifically introductory > tutorials...particularly DBIx::Class. All have active mail lists, and > strong communities of people who are always willing to help. > > http://cgi-app.org/http://search.cpan.org/~samtregar/HTML-Template-2.6/Template.pmhttp://search.cpan.org/dist/DBIx-Class/ > > I'll provide examples (or all my code itself) if you're interested. > > Cheers, > > Steve > > ps. I've read up a bit on Catalyst, but by that time I was already too > heavily using CGI::App to even consider changing. I do have another > project on the go that will require a lighter-weight gui front-end, so > I'm considering trying it out for that.- Hide quoted text - > > - Show quoted text -
Shlomi and Steve - Thank you for your suggestions, they are very helpful and I'm investigating now. I think I'd like to put everything into a single CGI script as you suggest Steve. As I progress, I'll likely improve upon it's capabilities but for now I am looking to get something into place. What you describe of your work sounds impressive but maybe a bit advanced for me at this point. I wouldn't mind seeing some of your code for the basic structure but I hadn't planned on using HTML::Template (probably should moving forward). I am certain that what you describe is the way to go about doing this in is best form but I think my learning curve may be longer for that and I really want to get something in place that works and improve from there. Thanks again, and if you have basic structure that you can share I'd be very interested. Best regards, Herb -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/