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

I have a Perl script that is an action page for a Cold Fusion form where it that takes Cold Fusion parameters and passes them to my script for mailing then passes the parameters to a Cold Fusion action page. Everything works great but was wondering if I can hide the url parameters that show in the url on my redirect:
#!/usr/local/bin/perl -w use strict; use CGI qw(:standard); #Perl web CGI module use CGI::Carp qw(fatalsToBrowser); my $query = new CGI; my $name = $query->param("name") || ""; my $city = $query->param("city") || ""; #do perl mail stuff here #etc...... #now pass parameters here print $query->redirect("http://webserverhere/mydirectory/act.cfm?name= +$name&city=$city");
Here is how the url looks in the browser on my Cold Fusion action page after a form is submitted with 'Name' value of Richard and 'City' value of Atlanta. Can I hide those values so they dont show in the url???
http://webserverhere/mydirectory/act.cfm?name=Richard&city=Atlanta

Replies are listed 'Best First'.
Re: Hiding passed values in url
by matija (Priest) on Mar 22, 2004 at 15:34 UTC
    To hide the parameters you would have to do a POST request.

    There are two problems with that:

    1. The CF script would have to support POST.
    2. You can't do a POST redirect with any reliability. There are some browsers for which it works, but for most it doesn't.
    If you absolutely need to do this, you should use LWP::UserAgent, make a POST request, and then print it's result. The only drawback is that your CF script will see all the requests coming from the server running your script - that may or may not be a problem, depending on your application.
      I am looking into the UserAgent module and here is my attempt but it doenst seem to be working.
      use strict; use CGI qw(:standard); use LWP::UserAgent; use HTTP::Request::Common; my $query = new CGI; my $name = $query->param("name") || ""; my $city = $query->param("city") || ""; #do perl mail stuff here #etc...... $ua = LWP::UserAgent->new; $ua->request(POST 'http://webserverhere/mydirectory/act.cfm', [name => + $name, city => $city]); #not sure what do to from here?
        You are throwing away the result of the request. You should do something like:
        $result=$ua->request(POST 'http:.... if ($result->is_success) { # Everything OK print $result->content; # send everything to the user } else { # There was an error in the CF script die "or do something equaly drastic"; }