Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Feb 1999 08:27:56 -0800
From:      dan@wolf.com
To:        keith@apcs.com.au, questions@FreeBSD.ORG
Subject:   Re: www cgi forms
Message-ID:  <19990216082756.A31610@ns.wolf.com>
In-Reply-To: <XFMail.990216203707.keith@apcs.com.au>; from Keith Anderson on Tue, Feb 16, 1999 at 08:37:07PM %2B1100
References:  <XFMail.990216203707.keith@apcs.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
> I'm having a problem passing information to my cgi's.
> I made a little test program to echo back anything I sent it (see below eecho.c)

Yep, I see the problem - neither of the 2 recognized methods
of transferring info to a CGI (POST and GET) pass info via
calling arguments.  

If you use GET, the form values getted passed through the
QUERY_STRING environment variable.  If you use POST the
form values get passwd via stdin with the total length
of all variables passed in the CONTENT_LENGTH environment 
variable.

I recommend "CGI Developers Guide" by Eugene Kim.  From Chapter
5 of his book, there's a function called ReadParse that does 
what you want in Perl.  I'll leave it to you to recode it 
in C :-)

sub ReadParse {
   local (*in) = @_ if @_;
   local ($i, $key, $val);

   if (&MethGet) {
      $in = $ENV{'QUERY_STRING'};
   } elsif (&MethPost) {
      read(STDIN, $in, $ENV{'CONTENT_LENGTH'});
   }

@in = split(/[&;]/, $in);

.... then continues to unescape the escaped values.

Dan Mahoney
dan@wolf.com


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990216082756.A31610>