How do I get perl to print the input from a HTML form to a .txt file?

tim85a

New member
I've got the code below....


<FORM ACTION="/perl-bin/signup.pl" METHOD="POST">
<P>
<INPUT TYPE=TEXT NAME="name" SIZE=20 STYLE="width: 4.34cm; height: 4.34cm">
<INPUT TYPE=TEXT NAME="address" SIZE=20 STYLE="width: 4.34cm; height: 5cm">
<br>
<br>
<INPUT TYPE=SUBMIT VALUE="Tell us Your Address">

How do I get signup.pl to wight the user input in to a file called address.txt?
 
use strict;
use warnings;
use CGI;
my $cgi = new CGI;
my @asNames = $cgi->param;
open TXT, '>', 'address.txt' or die;
foreach my $sName (@asNames)
{
my $sValue = $cgi->param($sName);
print TXT qq{$sName is $sValue\n};
}
close TXT;
__END__
 
Back
Top