Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HELP WITH MY CGI PLEASE *(or maybe HTML)

Posted on 1997-07-09
2
Medium Priority
?
225 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
2 Comments
 
LVL 5

Accepted Solution

by:
icd earned 100 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

927 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