perlquestion
bladx
Hey everyone<br><br>
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.<br><br>
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.<br><br>
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.<br><br>
I did take a long look at this node: [Q / A and HTML::Template techniques...|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:<br>
<code>
#!/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_params => 0);
$template->param(
BOX =>
$cgi->popup_menu(-name=>'color',
-values=>['red','green','blue','chartreuse']),
BOX2 =>
$cgi->textfield('name'),
);
print $template->output();
</code><br>
Also here is the .tmpl file:
<code>
<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>
</code><br>
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!
<br><br>
<font face=arial color=#333333 size=5>A</font><font face=arial color=#333333 size=4>n</font><font face=arial color=#666666 size=3>d</font><font face=arial color=#666666 size=2>y</font> <font face=arial color=#999999 size=1>S</font><font face=arial color=#999999 size=2>u</font><font face=arial color=#666666 size=3>m</font><font face=arial color=#666666 size=4>m</font><font face=arial color=#cccccc size=5>e</font><font face=arial color=#dddddd size=4>r</font><font face=arial color=#bbbbbb size=3>s</font>