Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

CGI not catching parameters?

by hallikpapa (Scribe)
on Aug 17, 2007 at 01:37 UTC ( #633198=perlquestion: print w/replies, xml ) Need Help??

hallikpapa has asked for the wisdom of the Perl Monks concerning the following question:

I have this front end javascript that calls my perl like this when I click a link:
cgi-bin/rpt.pl?dataname=ASRHOUR
The problem is, the very first thing I do in the perl is check which parameter for dataname is sent, but it isn't populating! Here is the beginning:
use strict; use File::Glob ':glob'; use DBI; use JSON; use POSIX qw(strftime); use POSIX ":sys_wait_h"; use warnings; use CGI; use CGI::Carp qw/fatalsToBrowser/; use Data::Dumper; my $query = CGI->new; my $reportname = $query->param('dataname'); print $query->header; print Dumper $query;
And nothing is pushed into $reportname. It's blank. If I execute the script directly, and not thru the button click, it reports data fine. The kicker is, I have the newest Firebug in firefox installed, so it's SHOWING me the correct parameter name. If I hard code $reportname, it works great. So basically I execute
http://localhost/cgi-bin/rpt.pl?dataname=ASRHOUR
It's fine I see in firebug this being executed through the GUI:
http://localhost/cgi-bin/rpt.pl?dataname=ASRHOUR
And nothing happens. So I am under the impression I am not catching the parameter correctly. Also, under the params section in the Firebug, it shows the correct parameter name & value. Please help, I been staring at this all day.

Replies are listed 'Best First'.
Re: CGI not catching parameters?
by sfink (Deacon) on Aug 17, 2007 at 03:52 UTC
    You are mixing URL parameters and POST parameters. That's a little funky, though common. See the section of the CGI.pm documentation titled "MIXING POST AND URL PARAMETERS". The short answer is that you'll have to get your 'dataname' via url_param() instead of the usual param().
      You sir, have relieved so much pressure off my neck...thank you
Re: CGI not catching parameters?
by Gangabass (Vicar) on Aug 17, 2007 at 03:11 UTC

    Maybe some kind of your browser caching mechanism?

    Did your try to clear cache before click on the button?

      I clear everything each time. Cookies, downloaded temp files, etc... I am stumped and COMPLETELY lost So in Firebuge, this is what I see:
      PARAMS: dataname ASRHOUR
      POST dir ASC limit 12 sort ID start 0
      And when I print the contents of the $query, I get this:
      RESPONSE $VAR1 = bless( { '.parameters' => [ 'start', 'limit', 'sort', 'dir' ], 'use_tempfile' => 1, 'dir' => [ 'ASC' ], 'sort' => [ 'ID' ], '.charset' => 'ISO-8859-1', '.cookies' => { 'PHPSESSID' => bless( { 'value' => [ +'2a4176bd2b0457d34949778a2d910 36e' ], 'name' => 'PH +PSESSID', 'path' => '/' }, 'CGI::Cookie +' ), 'ys-reportDate' => bless( { 'value' = +> [ + 's:2007-08-16' + ], 'name' => + 'ys-reportDate', 'path' => + '/' }, 'CGI::Co +okie' ) }, '.fieldnames' => {}, 'limit' => [ '12' ], 'escape' => 1, 'start' => [ '0' ] }, 'CGI' );
      So it's showing somehting in the CGI params, but not what is listed in Firebug? Huzzah? again, The script is executed like this rpt.pl?dataname=ASRHOUR And it's capturing everything but what I tell it to capture?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://633198]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2022-10-06 00:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (26 votes). Check out past polls.

    Notices?