Gossamer Forum
Home : General : Perl Programming :

Help with a simple cgi program

Quote Reply
Help with a simple cgi program
Hi All,

I've used this code to receive data transmitted via a POST.


read( STDIN,$buffer,$ENV{CONTENT_LENGTH} );

@string = split( /&/,$buffer );

foreach $str( @string )
{
( $name,$value ) = split( /=/,$str );

$value =~ tr/+/ /;

$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$FORM{ $name } = $value;
}

I was able to print all the names and their values.

It works well. However, I was wondering if I can use the same code to receive
the data entered in the TEXTAREA.

For example : print"<b1>$FORM{ z0comments }</b1></p>\n";

I am at work and not at my computer to try it. I just wanted to know if it was possible.

TEXTAREA COLS="40" ROWS="4" NAME="z0comments">


Thanks,
Mike

Quote Reply
Re: [TheSafePick] Help with a simple cgi program In reply to
It should work fine.... however it is highly recommended you use the CGI module to handle form input instead.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [TheSafePick] Help with a simple cgi program In reply to
Why not use CGI.pm?

Code:
use CGI;

my $IN = new CGI;

print $IN->header(); # prints out a header.. same as print "Content-type: text/html \n\n";

print $IN->param('variable');

CGI.pm is a lot better at handling both POST, and GET.... and even handles things like 'multi-selects' etc pretty well (by putting then in an array).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Help with a simple cgi program In reply to
I would use cgi.pm as well. Helps reduce lot of code writing on your own.