dmanb
asked on
HELP WITH MY CGI PLEASE *(or maybe HTML)
I'm having a lot of trouble getting all this to work. Would someone
please read through it for me and give me some suggestions. I'm just
a newbie here....
I'm trying to allow the form input to parse via the cgi and post then
to another page. Like a guestbook actually. It's more to be a
bulletin wall.
I thank you in advance for any help you might offer....
dbenson@hopsgroup.com
Here's the form to send the input...
<html>
<head>
<title>Bulletin Board Submission Form</title>
</head>
<body bgcolor="#FFFBF0" text="#000000">
<p>
<center>
<form method=POST action="http://ns.netmcr.com/cgi-bin/dmanb/bull.pl">
Your Name Please: <input type=text name="usrname" size=20><br>
Your E-Mail Address: <input type=text name="email" size=17><br>
Your Comment Please: <textarea wrap="virtual" rows=7 cols=17
name="comment"></textarea> <br>
<input type=submit value="Touch Me">
</center>
</body>
</html>
here's the cgi....
#!/usr/bin/perl
#This is a Bulletin Board
$bull="../../../../home/dm anb/public _html/bull /bull.htm" ;
$bull_url="http://ns.netmcr.com/~dmanb/bull/bull.htm";
$bull_cgi_url="http://ns.netmcr.com/cgi-bin/dmanb/bull.pl";
read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $input);
foreach $pair (@pairs) {
($name, $value) = split (/=/, $pair);
$name=~ tr/+/ /;
$name=~ s/%([a-fA-F0-9][a-fA-F0-9] )/pack("C" ,
hex($1))/eg;
$value=~ tr/+/ /;
$value=~s/%([a-fA-F0-9][a- fA-F0-9])/ pack("C",
hex($1))/eg;
$FORM{$name} = $value;
}
$usrname = $FORM{'usrname'};
$email = $FORM{'email'};
$comment = $FORM{'comment'};
$comments =~ s/<([^>]|\n)*>//g;
open(FILE, ">$bull") || die "I can't open $bull\n";
@file = <FILE>;
close(FILE);
$sizefile = @file;
open (FILE, ">$bull") || die "I can't!\n";
for($a = 0; $a <= $sizefile;
$sizefile++) {
$_ = $file[$a];
if(/<!--begin-->/) {
print FILE "<!--begin-->\n";
print FILE "<p><a
href=\"mailto:$FORM{'email '}\">$FORM {'usrname' }</a><br>\ n";
print FILE "$FORM{'comment'}</p>\n";
} else {
print $_;
}
}
close(FILE);
here's the resulting page....
<html>
<head>
<title>Bulletin Board</title>
</head>
<body bgcolor="#FFFBF0" text="#000000">
<p>
<center>
This Bulletin Board begun on 07-07-97
</center>
</p>
<!--begin-->
</body>
</html>
please read through it for me and give me some suggestions. I'm just
a newbie here....
I'm trying to allow the form input to parse via the cgi and post then
to another page. Like a guestbook actually. It's more to be a
bulletin wall.
I thank you in advance for any help you might offer....
dbenson@hopsgroup.com
Here's the form to send the input...
<html>
<head>
<title>Bulletin Board Submission Form</title>
</head>
<body bgcolor="#FFFBF0" text="#000000">
<p>
<center>
<form method=POST action="http://ns.netmcr.com/cgi-bin/dmanb/bull.pl">
Your Name Please: <input type=text name="usrname" size=20><br>
Your E-Mail Address: <input type=text name="email" size=17><br>
Your Comment Please: <textarea wrap="virtual" rows=7 cols=17
name="comment"></textarea>
<input type=submit value="Touch Me">
</center>
</body>
</html>
here's the cgi....
#!/usr/bin/perl
#This is a Bulletin Board
$bull="../../../../home/dm
$bull_url="http://ns.netmcr.com/~dmanb/bull/bull.htm";
$bull_cgi_url="http://ns.netmcr.com/cgi-bin/dmanb/bull.pl";
read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $input);
foreach $pair (@pairs) {
($name, $value) = split (/=/, $pair);
$name=~ tr/+/ /;
$name=~ s/%([a-fA-F0-9][a-fA-F0-9]
hex($1))/eg;
$value=~ tr/+/ /;
$value=~s/%([a-fA-F0-9][a-
hex($1))/eg;
$FORM{$name} = $value;
}
$usrname = $FORM{'usrname'};
$email = $FORM{'email'};
$comment = $FORM{'comment'};
$comments =~ s/<([^>]|\n)*>//g;
open(FILE, ">$bull") || die "I can't open $bull\n";
@file = <FILE>;
close(FILE);
$sizefile = @file;
open (FILE, ">$bull") || die "I can't!\n";
for($a = 0; $a <= $sizefile;
$sizefile++) {
$_ = $file[$a];
if(/<!--begin-->/) {
print FILE "<!--begin-->\n";
print FILE "<p><a
href=\"mailto:$FORM{'email
print FILE "$FORM{'comment'}</p>\n";
} else {
print $_;
}
}
close(FILE);
here's the resulting page....
<html>
<head>
<title>Bulletin Board</title>
</head>
<body bgcolor="#FFFBF0" text="#000000">
<p>
<center>
This Bulletin Board begun on 07-07-97
</center>
</p>
<!--begin-->
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER