Re: HTML/CGI: how do i use POST

Stu Harris (sirrah@baluga.maximumaccess.com)
Fri, 13 Dec 1996 18:19:41 -0800 (PST)


Message-Id: <m0vYjhV-00016RC@baluga.maximumaccess.com>
From: sirrah@baluga.maximumaccess.com (Stu Harris)
Subject: Re: HTML/CGI: how do i use POST
To: Fred_Deroche_at_corpsoftnorwood4@stream.com
Date: Fri, 13 Dec 1996 18:19:41 -0800 (PST)
Cc: www-html@w3.org
In-Reply-To: <9611138505.AA850520263@smtpmail.stream.com> from "Fred_Deroche_at_corpsoftnorwood4@stream.com" 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***************
>      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN">
>      <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 fred.ci.

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 
code.....

>      **********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.

Stu