http://www.perlmonks.org?node_id=135865

bladx has asked for the wisdom of the Perl Monks concerning the following question:

Hey everyone

I have been working on a small CGI script lately, and things have been going well. However, I have come up against a sort of problem.

My main goal so far of this "project" is to simply: Retrieve data from MySQL via the DBI module -> display this data in HTML form -> make a form for someone to input a row in the MySQL DB -> display contents of DB again in HTML form.

So far, everything but one of those parts of the project so far are completed. The part I don't know how to do yet is the form part. I am using HTML::Template for all of the HTML part, and am not sure how I can use a form with this (since I don't want to mirror too many cases or loops in the template that could have been done in the acutal .pl/.cgi program.

I did take a long look at this node: Q / A and HTML::Template techniques... and got some ideas as to how to do this *kind of*. But I don't know quite where to go with the code I have come up with which is displayed here:
#!/usr/bin/perl -w use strict; use HTML::Template; use CGI; use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; print $cgi->header; my $template = new HTML::Template(filename => "1.tmpl", die_on_bad_par +ams => 0); $template->param( BOX => $cgi->popup_menu(-name=>'color', -values=>['red','green','blue','chartreuse'] +), BOX2 => $cgi->textfield('name'), ); print $template->output();

Also here is the .tmpl file:
<html> <title>test</title> <body> <form> <table border=1 > <tr> <td> Color1: <TMPL_VAR NAME="BOX"> <br></td> <td> What is your name?: <TMPL_VAR NAME="BOX2"> <br> </td> <td> <input type=submit> </td> </table> </form> </body> </html>

Hopefully my question(s) are clear enough to answer, or at least to point to where I can find out how to do it in a correct manner. Thanks for any and all help or comments regarding this question!

Andy Summers