Re: HTML/CGI: how do i use POST

Stu Harris (
Fri, 13 Dec 1996 18:19:41 -0800 (PST)

Message-Id: <>
From: (Stu Harris)
Subject: Re: HTML/CGI: how do i use POST
Date: Fri, 13 Dec 1996 18:19:41 -0800 (PST)
In-Reply-To: <> from "" at Dec 13, 96 03:18:56 pm

>      Please help me understand what I'm doing wrong...
>      When I click/press the submit key, my HTML file 
>      displays my CGI file on the screen ...
>      I want it to add to a file (fred.txt) and not display it results...
>      thanks, fred
>      **********this is fred.htm***************
>      <HTML>...
>      <form method="post" action="./fred.cgi">    

There's quite a bit wrong with this, but the first thing is that the 
above line suggests you're trying to run CGI in the same directory as 
html. This has the undesirable and highly insecure effect of printing out 
the text of your perl rountine on the user's screen, as you have noticed.

Create a directory beneath your html directory (NOT at the same level). 
This is usually called cgi-bin. Next, find out what needs to be done to 
validate cgi in that directory. You may need an .htaccess file, or it 
might be simply a matter of permissions on the server. Put fred down 
there and chmod a+x

The above line will now need to be:
      <form method="post" action="cgi-bin/fred.cgi">    

That'll move you on to the next bunch of things that are wrong with your 

>      **********this is fred.cgi***************
>      #!/usr/bin/perl
>      ....
>      open ( MAIL, ">> fred.txt") || die print " cannot open mailprog";
>      print MAIL "name=" $contents('name') \n;
>      print MAIL "org= " $contents('org') \n;
>      print MAIL "tele=" $contents('tele') \n;
>      close(mail);

Wozzis $contents( ) array????  Did you create it from the incoming 
name=value pairs up there while the row of dots was happening? I sure 
hope so, because it has no meaning otherwise. Quite possibly your 
parentheses need to become braces, too. I could moan on but I'll stop 
right there and hope I've been helpful.