Forum Moderators: coopster & phranque

Message Too Old, No Replies

Want to Output an HTML page using submitted form data

Need Perl Script

         

RussellC

4:04 pm on May 13, 2002 (gmt 0)

10+ Year Member



Anyone know of a good, easily configurable Perl script that simply takes form info and when submit is pressed, it takes them to an HTML formatted page with all the info that they entered. It needs to have an HTML output page that I can customize. Is this possible?

Thanks

RussellC

7:35 pm on May 15, 2002 (gmt 0)

10+ Year Member



Anyone know of anything?

mivox

7:50 pm on May 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think Formmail has the option to send the visitor to a "here is the information you submitted" page.

You could probably customize that page's appearance in the perl code somewhere, but the primary function of the script is to email you the form info they submit.

I don't know of any scripts who's sole function is to generate an html page displaying form input though...

PsychoTekk

8:22 pm on May 15, 2002 (gmt 0)

10+ Year Member



dunno if that's what you are looking for:
[post.cgi]
#!perl

use strict;
use CGI::Carp qw(fatalsToBrowser);

print <<"FIN";
Content-type: text/html; charset=iso-8859-1

<html>
<head>
<title>Post Text</title>
</head>
<body>
<form action="post.pl" method="post">
<textarea rows="6" cols="45" wrap="VIRTUAL" name="usertext"></textarea><p>
<input type="submit" value="Post"></p>
</form>
<p>
FIN
open(db, "data.tmp") ¦¦ die "datafile not found";
my @Lines = <db>;
close(db);
foreach(@Lines,)
{print "$_\n";}
print "</body></html>\n";

[post.pl (in the same folder)]
#!perl

read(STDIN, my $Data, $ENV{'CONTENT_LENGTH'});
my @Formfields = split(/&/, $Data);
my ($Field, $Name, $Value);
my %Form;
foreach $Field (@Formfields)
{(my $Name, my $Value) = split(/=/, $Field);
$Value =~ tr/+/ /;
$Value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$Value =~ s/</</g;
$Value =~ s/>/>/g;
$Form{$Name} = $Value;}
open (db, "> data.tmp");
print (db "$Form{usertext}\n");
close (db);
print "Location: post.cgi\n\n";

a file (data.tmp) will be created the first time you use the script
(in case the script is not executed because of that error create that
file yourself)

RussellC

5:13 pm on May 16, 2002 (gmt 0)

10+ Year Member



how about a script that will send an html formatted e-mail with the info...would that be easier?