Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

removing/stripping query string params

by drfrog (Deacon)
on Jul 02, 2003 at 18:53 UTC ( [id://270900]=perlquestion: print w/replies, xml ) Need Help??

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

i tried searching here with no luck

say im using CGI to pass params to a script

like http://foo.bar.com/cgi/perl.pl?arg=arg&arg2=arg2

how can i strip the params from the URL so it doesnt show like that upon returning to the clients browser?

would just a undef $q->params(); be enough?

Replies are listed 'Best First'.
Re: removing/stripping query string params
by Tomte (Priest) on Jul 02, 2003 at 19:05 UTC

    Frankly, this doesn't make much sense.

    if you don't want the query-string to show up in the location-field of the browser, use POST instead of GET as form-method, this has nothing to do with the cgi-script, though.

    regards,
    tomte


    Hlade's Law:

    If you have a difficult task, give it to a lazy person --
    they will find an easier way to do it.

Re: removing/stripping query string params
by valdez (Monsignor) on Jul 02, 2003 at 19:13 UTC

    There is a function/method called delete_all in CGI.pm that does what you need, but I think you have a different problem: you can't change the url showed by clients browsers inside your script; the url is used to invoke the script and it is not the result of your operations unless you issue a redirect. If your final purpose is to hide the params you can set METHOD attribute of FORM with POST.

    Ciao, Valerio

Re: removing/stripping query string params
by KPeter0314 (Deacon) on Jul 02, 2003 at 19:09 UTC
    Assuming you are using something like Apache, try the webserver environment to get the URL for your script:
    my $url = $ENV{SCRIPT_NAME};
    If you are trying to hide the options you will need the POST method.

    -Kurt

Re: removing/stripping query string params
by artist (Parson) on Jul 02, 2003 at 19:24 UTC
    You can see the example of what you want by voting on let's say this reponse node. The URL after voting would not consist extra parameter after index.pl in the browser.

    If you want to invoke a CGI without a form tag, you are asking almost impossible, because it's not in your hand except 'redirection' by your CGI script.

    artist

      thanks all
      http://search.cpan.org/author/LDS/CGI.pm-2.97/CGI.pm#DELETING_ALL_PARAMETERS_
      seems right.
      although i should be probably be using post as well ;)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://270900]
Approved by valdez
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2024-04-25 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found