user2912312 user2912312 - 1 year ago 84
Perl Question

How to pass value to cgi script from HREF link

I do have script with href that calls a cgi script, and I want to pass a value to cgi script from href..first script is link.cgi and it has a line like this:

print "<TD align=center><FONT SIZE='4'><a href='../cgi-bin/call.cgi?param=$path1'>$v_rel</a></FONT>\n";

I do have these line in call.cgi:

use CGI;
my $cgi = CGI->new();
my ($param) = $cgi->param('param');
print ".....the value is $param\n";

I get error here when I click the link in which it calls call.cgi,I guess it does not pass the param to call.cgi, any good people out there can help on this..thanks in advance.

Answer Source

Removing -T is usually not a good solution. You probably have a potential security issue in your code, and perl with -T alarmed you about it. By removing -T, you just masked it but it's still there. The return value of $cgi->param() is tainted and has to be cleaned up before you pass it to many functions.

Instead, add use CGI::Carp qw/fatalsToBrowser/; as proposed by @Chris, and if you still get this error have a look at your server error logs that will contain more information about the error.

Sometimes it helps being able to run from the command line and see the errors directly on the command line. Set QUERY_STRING to your parameter and run your script:

export QUERY_STRING=param=WhateverYourPath1Is
perl /path/to/call.cgi

NB: you may have to define a few other CGI environment variables depending on your script.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download