UNKNOWN
=**************************************
= for :Form to File
=**************************************
The Question is, if there was a copyright would it stop people anyway ;) lol
=**************************************
= Name: Form to File
= Description:This Perl script is a example of form to file, what it does is when you fill in the form it will save it to a the file specified as a variable at the top. If you post more than once it puts them in the same file one after the other post. Fields can be added but will involve changing the cgi alittle, this is for webmasters who dont want users to submit their own made fields form their own made html forms (eg, trying to hack the script and mess it up). All you have to do is run the script, it has a form built in.
= By: Richard Leishman
=
=
= Inputs:None
=
= Returns:None
=
=Assumes:None
=
=Side Effects:None
=This code is copyrighted and has limited warranties.
=Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.284/lngWId.6/qx/vb/scripts/ShowCode.htm
=for details.
=**************************************
#!/path/to/perl
##################
# Please link me on your website
# Http://www.L22.co.uk
##################
#what the file will be saved as
$save_to = "saved.txt";
#starting to view page
print "Content-type: text/html\n\n";
#setting up form inputs
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<([^>]|\n)*>//g;
$value =~ s///g;
$FORM{$name} = $value;
}
#Choosing which root it will take
if ($ENV{'QUERY_STRING'} =~ /Add/) { &Add; }
elsif ($ENV{'QUERY_STRING'} =~ /Main/) { &Main; }
else { &Main; }
#This is the form you fill in
sub Main {
print "
\n";
}
#when you click Send it runs this
sub Add {
#saving the file
open FILE, ">>$save_to" or print "[ERROR: Cannot open file to save to]";
print FILE "$FORM{'field'}\n";
$news = "$FORM{'field'}";
close(FILE);
}