I appologize for my ignorance, but I'm still new at this! I'm trying to write a multiple form survey but am running into 2 problem with my code. I most like have some wrong ideas about how certain things work. For any clarification I'll be most thankfull.
Problem 1.) The script proceeds to the 2nd form without me completeing the 1st.
Problem 2.) The 2nd form is upended at the bottom of the 1st, not in its own window.
#!/usr/bin/perl
for ( $i=1 ; $i<=2 ; $i++ ) {#loop over # of forms
&display_file ($i);
%box = &read_query_string; # Read keys and values
open(OFILE,">> temp.dat") || die "can't open output file:\n$!";
print OFILE "$box{'age'} \n";
close OFILE;
};
sub read_query_string
{
local ($buffer, @pairs, $pair, $name, $value, %FORM);
# Read in text
$ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
if ($ENV{'REQUEST_METHOD'} eq "POST")
{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else
{
$buffer = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%(..)/pack("C", hex($1))/eg;
$FORM{$name} = $value;}
%FORM;
};
sub display_file
{
($nummer) = @_;
open (FILE, "< ../FPR/$nummer.htm" ) || die "can't read input file
+:\n$!";
print "Content-type: text/html", "\n\n";
while (<FILE>) {print;}
close (FILE);
};