For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2007 > variable in cgi param









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 variable in cgi param
Ubergoonz

2007-07-23, 6:59 pm

Hi,

I am trying to parse a param in cgi script.

basically how can i make use of a for loop to parse the variables, from the
url
http://someplace/cgi-bin/script.cgi...blah&totalkey=3


for ($1=1; $i <= $cgi->param('totalkey') ; $i++) {
print "<li>$i - $cgi->param('ip$i') cgi->param('hn$i') ";
}
but output seems to be HASHblah ...




--

ubergoonz

Jm

2007-07-23, 6:59 pm

i have used this, just to display all param()s and verify the data
being passed. i'm thinking someone showed me a newer version for
looking at multiple values for checkboxes, etc. but i'm not sure and i
don't have more recent code available to verify.

hope this helps


#############

foreach my $param (param())
{
my $value = param($param);
$message .= "param \"$param\" = \"$value\" <br />";
}

#############

On 7/23/07, ubergoonz <ubergoonz@gmail.com> wrote:
> Hi,
>
> I am trying to parse a param in cgi script.
>
> basically how can i make use of a for loop to parse the variables, from the
> url
> http://someplace/cgi-bin/script.cgi...blah&totalkey=3
>
>
> for ($1=1; $i <= $cgi->param('totalkey') ; $i++) {
> print "<li>$i - $cgi->param('ip$i') cgi->param('hn$i') ";
> }
> but output seems to be HASHblah ...
>
>
>
>
> --
>
> ubergoonz
>



--
since this is a gmail account, please verify the mailing list is
included in the reply to addresses
Thomas Polnik

2007-07-23, 6:59 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

> for ($1=1; $i <= $cgi->param('totalkey') ; $i++) {

$1 is not $i - If you would use 'use strict', you would find mistakes
like this very easy :)
> print "<li>$i - $cgi->param('ip$i') cgi->param('hn$i') ";

Please try:
print "<li>$i - " . $cgi->param('ip'.$i) . ' ' . cgi->param('hn'.$i);

Good Luck with 'use strict',
thomas.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFGpMGmbTea+gJmESYRAjfGAKCGQypOlVaN
BBkEc6mbrfaNeHdXFACfciml
veobtOlx6VC2NnGF7/bV/1M=
=SNcR
-----END PGP SIGNATURE-----

John Moon

2007-07-23, 6:59 pm

-----Original Message-----
From: ubergoonz [mailto:ubergoonz@gmail.com]=20
Sent: Monday, July 23, 2007 10:06 AM
To: Perl Beginners
Subject: variable in cgi param

Hi,

I am trying to parse a param in cgi script.

basically how can i make use of a for loop to parse the variables, from
the
url
http://someplace/cgi-bin/script.cgi...=3Dblah&ip2=3D=
xxx
..xxx.xxx.xxx&hn2=3Dblah&ip3=3Dxxx.xxx.xxx.xxx&hn3=3Dblah&totalkey=3D3


for ($1=3D1; $i <=3D $cgi->param('totalkey') ; $i++) {
print "<li>$i - $cgi->param('ip$i') cgi->param('hn$i') ";
}
but output seems to be HASHblah ...



[>>] Here away...

my %REQUEST =3D ( # expected parameters!
ACCT =3D>'',
PRODUCT =3D>'',
PERIOD =3D>'',
REPORT_PERIOD =3D>'',
OPTION =3D>'',
ACTION =3D>'',);

foreach ($q->param) {
$REQUEST{"$_"}=3D$q->param("$_");
}
# NOT checking for parameters that are a list!=20
Sponsored Links







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

Copyright 2008 codecomments.com