Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] How to do a CGI redirect with arguments?

Expand Messages
  • david wright
    ... yup, as advertised. ... yup, I don t see the redirect method accepting an hashref as a arg in the docs. ... yup, again, I don t see the redirect method
    Message 1 of 4 , Jan 14, 2009
    • 0 Attachment
      > print
      > $q->redirect(-url=>'http://pubswww.kl.imgtec.org:8080/cgi-bin/displaytest.cgi');
      > # No arguments works

      yup, as advertised.

      > print
      > $q->redirect(-url=>'http://pubswww.kl.imgtec.org:8080/cgi-bin/displaytest.cgi',
      > \%args); # This fails

      yup, I don't see the redirect method accepting an hashref as a arg in the docs.

      > print $q->redirect # # This fails
      > too!
      > (
      >
      > -url=>'http://pubswww.kl.imgtec.org:8080/cgi-bin/displaytest.cgi',
      > -nph=>1,
      > {
      >
      > 'never' => 'hi',
      >
      > 'happen' => 'ho'
      > }
      > );

      yup, again, I don't see the redirect method accepting an hashref as a arg in the docs.

      You can of course accomplish what you seek by building up your url itself.

      my $url = 'http://pubswww.kl.imgtec.org:8080/cgi-bin/displaytest.cgi';
      $q->redirect(-url=> $url.'?will=hi&happen=ho');

      (it's possible I am missing in the docs how to accomplish it via a redirect with args, try perldoc CGI, if you haven't already)

      +David


      --- On Wed, 1/14/09, hooyar66 <hooyar66@...> wrote:

      > From: hooyar66 <hooyar66@...>
      > Subject: [PBML] How to do a CGI redirect with arguments?
      > To: perl-beginner@yahoogroups.com
      > Date: Wednesday, January 14, 2009, 1:46 PM
      > 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!
      >
      > Redirect without arguments works fine - but the various
      > approached
      > I've tried to send arguments all fail.
      >
      > I would really appreciate some help with this - I'm
      > sure/hope it's a
      > simple syntax issue
      >
      > Thanks
      > NJH
      >
      > test.cgi
      > ---------
      >
      > #!c:/perl/bin/perl.exe
      >
      > use strict;
      > use warnings;
      > use CGI;
      >
      > my $q = new CGI;
      >
      > my %args =
      > (
      > 'nev'   =>  'hi',
      > 'hod'   =>  'ho'
      > );
      >
      > print
      > $q->redirect(-url=>'http://pubswww.kl.imgtec.org:8080/cgi-bin/displaytest.cgi');
      > # No arguments works
      >
      > print
      > $q->redirect(-url=>'http://pubswww.kl.imgtec.org:8080/cgi-bin/displaytest.cgi',
      > \%args); # This fails
      >
      > print     $q->redirect # # This fails
      > too!
      >         (
      >            
      > -url=>'http://pubswww.kl.imgtec.org:8080/cgi-bin/displaytest.cgi',
      >             -nph=>1,
      >             {
      >                
      > 'never'   =>  'hi',
      >                
      > 'happen'   =>  'ho'
      >             }
      >         );
      >
      >
      >
      > print   "Content-Type: text/html\n\n",
      >         "The redirect seems to have
      > failed.";
      >        
      > ---
      >
      > displaytest.cgi
      > ---------------
      >
      > #!c:/perl/bin/perl.exe
      >
      > use warnings;
      > use strict;
      > use diagnostics;
      > use CGI;
      > use CGI::Carp qw(fatalsToBrowser);
      > use DBI;
      >
      > my $q = new CGI;
      >
      > print   $q->header(),
      >         $q->start_html(),
      >     '<h1>Test
      > redirection</h1>';
      >
      > print "Args: ", $q->param(), "<br>";
      >
      > foreach my $param($q->param())
      > {
      >     print "Initial: $param, Value:
      > ",$q->param($param),"<br>";
      > }
      >
      > $q->end_html;
      > exit();
      >
      >
      > ------------------------------------
      >
      > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo!
      > Groups Links
      >
      >
      >     mailto:perl-beginner-fullfeatured@yahoogroups.com
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.