From owner-freebsd-questions Tue Feb 16 8:35:11 1999 Received: from mail.greatbasin.net (mail.greatbasin.net [207.228.35.39]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id IAA06349 for ; Tue, 16 Feb 1999 08:35:09 -0800 (PST) (envelope-from dan@jgl.reno.nv.us) Received: from danco (jgl.reno.nv.us [207.228.2.142]) by mail.greatbasin.net (8.9.2/8.8.8) with SMTP id HAA18498; Tue, 16 Feb 1999 07:20:25 -0800 (PST) Message-ID: <05a401be59bf$ade2cc60$0200000a@danco.home> From: "Dan O'Connor" To: , Subject: Re: www cgi forms Date: Tue, 16 Feb 1999 07:18:58 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3155.0 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG The arguments from a form don't get passed as argv[] arguments. If your form uses METHOD=POST, you must read $CONTENT_LENGTH characters from standard input (stdin). If you use METHOD=GET the args are in $QUERY_STRING. here's the algorith I use (sorry, it's in Perl, but you can convert it to C): # Parse the form # Get the input if ($ENV{'REQUEST_METHOD'} eq 'GET') { $buffer = $ENV{'QUERY_STRING'}; } else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } } Have fun! --Dan -----Original Message----- From: Keith Anderson To: questions@FreeBSD.ORG Date: Tuesday, February 16, 1999 1:37 AM Subject: www cgi forms >Hi All > >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) > >sf I use all works fine but if I try a form nothing happens it runs >the script but with no arg's > > >Can some one point me to the right direction on this one. > >Thanks > >Keith Anderson > > > > >#include >#include > >int a; > >main(int argc, char * argv[]) >{ >printf("Content-type: text/html\n\n"); >printf("\n\nArg Test\n\n"); >printf("argc = %d\n",argc-1); >if (argc > 1) > { > printf("Args are\n"); > for (a = 1;a printf("%s\n",argv[a]); > } >printf("\n\n"); >exit(0); >} > > >--- > >"The box said 'Requires Windows 95, NT, or better,' so I installed FreeBSD." > > >---------------------------------- >E-Mail: Keith Anderson >Date: 16-Feb-99 >Time: 20:20:29 >Satelite Service 64K to 2Meg >This message was sent by XFMail >---------------------------------- > >To Unsubscribe: send mail to majordomo@FreeBSD.org >with "unsubscribe freebsd-questions" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message