rendered paste bodyprint "Content-type: text/html\n\n";
open(FORM, 'config/formulario.txt') || die "No pude abrir el archivo formulario.txt: $!";
while(<FORM>){
chomp;
($comentario, $tipocampo, $validacion, $nombre_en_db) = split(/:/, $_);
push @campos, $comentario;
}
my $formulario = CGI::FormBuilder->new(
method => 'post',
name => 'Rodilla',
title => 'RODILLA!!',
fields => \@campos,
font => 'Arial',
submit => 'Enviar',
);
if ($formulario->submitted && $formulario->validate){
#&conectar_db;
open(DB, 'config/datos_db.txt') || die "No pude abrir el archivo formulario.txt: $!";
while(<DB>){
chomp;
#($dbtype, $dbname, $host, $dbuser, $dbpass) = split(/\s/, $_);
@datos_db = split(/\s/, $_);
}
$db = DBI->connect("DBI:$datos_db[0]:database=$datos_db[1];host=$datos_db[2]", $datos_db[3], $datos_db[4], {RaiseError => 1});
my (@copia, $campo);
@campos = @copia;
foreach $campo (@campos){
push @copia, eval "$campo";
}
foreach (@campos) {
$_ = "\"\$" . "$_\",";
}
my $numero = @campos;
$numero = $numero -1;
chop($campos[$numero]);
print "@campos\n";
#$query = $db->prepare("INSERT INTO formulario VALUES(\"\", @campos);");
#$query->execute();
#print $formulario->confirm(template => 'templates/funciona.tmpl');
}
else{
print $formulario->render(header => 1);
}