For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > May 2004 > Post Method









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Post Method
Werner

2004-05-22, 11:32 am

Hi There,

I've got a html page that uses the following:

<form action="people.cgi" METHOD="GET" name="form1"
enctype="multipart/form-data">

and would like to change the "GET" method to the "POST" method.

my current people.cgi looks like:

$temp=$ENV{'QUERY_STRING'};
#read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$temp);

foreach $item(@pairs)
{
($key,$content)=split (/=/,$item,2);
$content=~tr/+/ /;
$content=~ s/%(..)/pack("c",hex($1))/ge;
$fields{$key}=$content;
}

what changes to I have to make to implement my variables using the "POST"
method.

Regards
Werner
David Dorward

2004-05-22, 11:32 am

On 14 May 2004, at 13:08, Werner wrote:
> and would like to change the "GET" method to the "POST" method.
>
> my current people.cgi looks like:
>
> $temp=$ENV{'QUERY_STRING'};
> ...
> what changes to I have to make to implement my variables using the
> "POST" method.


I'd bin that little lot in favour of the CGI module. Its robust and
handles POST and GET easily.

perldoc CGI

--
David Dorward
<http://dorward.me.uk/>
<http://blog.dorward.me.uk/>

Paul Archer

2004-05-22, 11:32 am

1:08pm, Werner wrote:

> Hi There,
>
> I've got a html page that uses the following:
>
> <form action="people.cgi" METHOD="GET" name="form1"
> enctype="multipart/form-data">
>
> and would like to change the "GET" method to the "POST" method.
>
> my current people.cgi looks like:
>
> $temp=$ENV{'QUERY_STRING'};
> #read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
> @pairs=split(/&/,$temp);
>
> foreach $item(@pairs)
> {
> ($key,$content)=split (/=/,$item,2);
> $content=~tr/+/ /;
> $content=~ s/%(..)/pack("c",hex($1))/ge;
> $fields{$key}=$content;
> }
>
> what changes to I have to make to implement my variables using the "POST"
> method.
>
> <form action="people.cgi" METHOD="GET" name="form1"

becomes
> <form action="people.cgi" METHOD="POST" name="form1"


As Marcel Gag-me would say, "Simple, non?"



------------------------------------------------------------------------
The Bible is not my Book and Christianity is not my religion. I could
never give assent to the long complicated statements of Christian dogma.
---------------------- Abraham Lincoln----------------------------------
Brad Lhotsky

2004-05-22, 11:32 am

On Fri, May 14, 2004 at 01:08:29PM +0100, Werner wrote:
> Hi There,
>
> I've got a html page that uses the following:
>
> <form action="people.cgi" METHOD="GET" name="form1"
> enctype="multipart/form-data">
>
> and would like to change the "GET" method to the "POST" method.
>
> my current people.cgi looks like:
>
> $temp=$ENV{'QUERY_STRING'};
> #read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
> @pairs=split(/&/,$temp);
>
> foreach $item(@pairs)
> {
> ($key,$content)=split (/=/,$item,2);
> $content=~tr/+/ /;
> $content=~ s/%(..)/pack("c",hex($1))/ge;
> $fields{$key}=$content;
> }


Scrap all that code. Its horribly outdated and broken.

use strict;
use CGI;

my $c = new CGI;
my %fields = ();

foreach my $name ($c->param) {
$fields{$name} = $c->param($value);
}

Hard to believe its 2004 and there is STILL code parsing the query
string itself.

>
> what changes to I have to make to implement my variables using the "POST"
> method.
>
> Regards
> Werner
>
> --
> To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org
> For additional commands, e-mail: beginners-cgi-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>


--
Brad Lhotsky <brad@divisionbyzero.net>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com