in reply to Redirect Page with POST

rather than using redirect method of CGI.pm or printing Location header, you can simply create a form with METHOD=POST and ACTION=url and the data you want to pass , pass them as hidden fields as below:-
#! /usr/bin/perl use CGI qw/ :standard/; # Initialise a html page print header("text/html"); # Start html page print start_html(-title =>'Test Page',-bgcolor =>'#ffffff'); # Start the query form print start_form(-name=>"test",-action=>"aa.cgi",-method=>"POST"); # send data using hidden fields print hidden(-name=>"tag1",-value=>"data1"), hidden(-name=>"tag2",-value=>"data2"), hidden(-name=>"tag3",-value=>"data3"); print end_form,end_html;
I hope this works, cheers.

Replies are listed 'Best First'.
Re^2: Redirect Page with POST
by bgreenlee (Friar) on Jul 14, 2004 at 06:44 UTC
    You still would need to encrypt the data if you did this, otherwise a View Page Source would reveal the "sensitive" information.

    Brad

      No one ever said the data was "sensitive", the OP just asked for a way to redirect without needing to shove all of the data into the URL (probably because he thought it looks ugly)

      The fact that teh OP wnats to "redirect a POST" implies that all of the "sensitive" data came from the user, so what differences does it make if the user sees it?

        thanks for all your help. hossman is exactly right, it's not sensitive data but merely the equivalent to building a watch that doesn't expose the clockwork. hmm, i will conclude from your various comments that there is no straight solution per se. any option that is not 100% compatible is out (javascript, 307 redirect etc..) i'm now thinking to go with LWP::Agent after all using the forwarded url, even though it will not actually forward, the results seem to be the same:
        require LWP::UserAgent; $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(POST => $forwarded_url); $req->content_type('application/x-www-form-urlencoded'); $req->content($parameters_from_input); my $res = $ua->request($req); print "Content-type: text/html\n\n"; print $res->content; exit;
        Only thing is, i remember reading somewhere that there might be some problems with headers and cookies etc. I'm testing it right now and cant see anything obvious. Caution flags anyone?