Re: How to send arguments with a redirect?

[email protected] (Gunnar Hjalmarsson) Thu, 15 Jan 2009 13:30:23 +0100
Newsgroups perl.beginners.cgi
Message-ID <[email protected]>
[email protected] wrote:
> Hi
> 
> I have the following two scripts test.cgi & displaytest.cgi
> 
> test.cgi is intended to redirect itself to displaytest.cgi and send
> some arguments.
> 
> The problem I am having is that I can never get the arguments
> successfully sent!

Try this in test.cgi:

use CGI;
use URI::Escape;

my $q = new CGI;

my $url =
'http://pubswww.kl.imgtec.org:8080/cgi-bin/displaytest.cgi';

my %args = (
     'nev'   =>  'hi',
     'hod'   =>  'ho'
);

my @args;
foreach my $key ( keys %args ) {
     push @args, uri_escape($key).'='.uri_escape($args{$key});
}
my $query = join ';', @args;

print $q->redirect("$url?$query");

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl