Solved

HELP WITH MY CGI PLEASE *(or maybe HTML)

Posted on 1997-07-09
2
213 Views
Last Modified: 2013-12-25
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/dmanb/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>

0
Comment
Question by:dmanb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
icd earned 50 total points
ID: 1829002
A number of problems (and perhaps still some more after this answer).

First of all you get a server error when the script is run on your site. Have you set the script to be world executable? Are the files it uses also world read and write?

I was not very sure about the long relative path for the $bull variable. Is this necessary?

The line:-

for($a = 0; $a <= $sizefile; $sizefile++) {

should be

for($a = 0; $a <= $sizefile; $a++) {

(And it should be on one line, perhaps it was wrapped only on experts-exchange).

Your script needs to output to stdout. The minimum should be:-

print <<__END__;
Content-type: text/html

<HTML><HEAD></HEAD><BODY>Hello world</BODY></HTML>
__END__

Note that there must be a blank line after the 'Content-type' and that there must be no white space before or after the final '__END__' line.

You will get an error if you do not output a valid document and this will apply to your 'die' statements. You need to re-code this so that error conditions are printed as an html document.

Fix these problems and we will see if it gets you any further.
0
 

Author Comment

by:dmanb
ID: 1829003
The help from this posting was minimal.  I thank you for your response, but everytime I perl the cgi file, it makes the output file change to 0 bytes.  I have no idea what's going on.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question