5 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl -wT
use strict;
use HTML::Template;
use CGI::Carp qw(fatalsToBrowser);
use CGI;
my $cgi = new CGI;
my $vars = $cgi->Vars;
my $tmpl = HTML::Template->new(filename => './form.tmpl');
my $statement = genstt('table', $vars);
$tmpl->param(STATEMENT => $statement);
print "Content-Type: text/html\n\n", $tmpl->output;
sub genstt {
my $tbl = shift;
my $vars = shift;
my $stt = ();
# Die erlaubten Parameter filtern ...
foreach my $param (qw(param1 param2 param3)) {
next unless defined $vars->{$param};
next if $vars->{$param} eq '';
# Parameter anhaengen
if (defined $stt) {
$stt .= ",$param='$vars->{$param}'";
} else {
$stt = "$param='$vars->{$param}'";
}
}
return $stt ? "insert into $tbl set $stt" : undef;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Form Config</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<TMPL_IF NAME="STATEMENT">
<pre>Statement: <TMPL_VAR NAME="STATEMENT"></pre>
</TMPL_IF>
<form action="/cgi/form.cgi" method="POST">
<table>
<tr>
<td>Param1</td>
<td><input name="param1" type="text" maxlength="40" value=""/></td>
</tr><tr>
<td>Param2</td>
<td><input name="param2" type="text" maxlength="40" value=""/></td>
</tr><tr>
<td>Param3</td>
<td><input name="param3" type="text" maxlength="40" value=""/></td>
</tr><tr>
<td></td>
<td><input type="submit" value="Absenden"></td>
</tr>
</table>
</form>
</body>
</html>
5 Einträge, 1 Seite |