Forum Moderators: coopster & phranque

Message Too Old, No Replies

Problem with &ReadParse

         

mjawanda

4:49 pm on Feb 9, 2004 (gmt 0)

10+ Year Member



Hi,

I am having a problem with retrieving data from a form.

My code looks like this

#!/usr/bin/perl
print "Content-type: text/plain\n\n";
require ("cgi-lib.pl");

if (&ReadParse) {
print "i_perl rules";
} else {
print "u_perl rules";
}

When I comment the if loop it doesnt give me a problem but if uncommented it doesnt execute either of the true or false statements.

Please help!

Thanks
Mandeep

Laxters

7:10 pm on Feb 11, 2004 (gmt 0)

10+ Year Member



&ReadParse usually requires a few parameters. You should have it as:

&ReadParse(*input);

The end result of your code would look like this:


#!/usr/bin/perl
require ("cgi-lib.pl");
print "Content-type: text/plain\r\n\r\n";
if (&ReadParse(*input)) {
print "i_perl rules"; }
else {
print "u_perl rules"; }

Be sure to check the documentation from [cgi-lib.berkeley.edu ]

andreew

4:48 am on Feb 20, 2004 (gmt 0)

10+ Year Member



When you submit the form (using POST method) it is submitted to the standard in file in the following format.

field=value&field1=value1&field2=value2&.....

so you could try something like this

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@dbinfo=split(/&/, $buffer);

foreach $info(@dbinfo){
($field,$value)=split(/=/, $info);
$equipvalues{$field}=$value;

}