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

hi monks,

how do i get rid of variable information on the URLs? example:
www.mypage.com/cgi-bin/script.cgi?ID=1&NAME=ME&YOU=YOU&HIM=HIM
shoud look like this: ww.mypage.com/cgi-bin/script.cgi

but i still wanna pass the variable values to script being called.

............................................................................
If only there were evil people somewhere insidiously committing evil deeds and it were necessary only to separate them from the rest of us and destroy them. But the line dividing good and evil cuts through the heart of every human being. And who is willing to destroy a piece of his own heart?
-Alexander Solzhenitsyn, novelist, Nobel laureate (1918- )

Replies are listed 'Best First'.
Re: funky URLs
by gryphon (Abbot) on Jun 30, 2001 at 00:33 UTC

    Sure. Just change the form method from a GET to a POST in your HTML page (or HTML page rendered by a Perl CGI) that ends up calling your script.

    <FORM action="/cgi-bin/script.cgi" method="post"> <INPUT type=text name="NAME" value="me"> ...

    This should clean things up nicely for you.

    -gryphon

      i'm not sending the info using a form. all the values are being sent with a link.

        Well, you didn't specify this in your original post. OK, fine. Here's a solution: Put your params that you need for the CGI into a series of hidden form fields. Then call a form submit from your link via a JavaScript call.

        <HTML><HEAD><TITLE>Some Page</TITLE> </HEAD><BODY bgcolor="#ffffff"> <FORM name=theform method=post action="/cgi-bin/script.cgi"> <INPUT type=hidden name=ID value=1> <INPUT type=hidden name=NAME value=ME> <INPUT type=hidden name=YOU value=YOU> <INPUT type=hidden name=HIM value=HIM> </FORM> <P>Here's a <A href="javascript:document.theform.submit();">link</a> for you.</P> </BODY></HTML>

        -gryphon

        Update: It was pointed out to me that not everyone uses JavaScript, and not everyone can use it. So this won't be an option that works perfectly for everyone, but it's all I could think of...

        You're asking how to send parameters with a url without sending them in the url. The question makes no sense. Either use a form with method="post", or pass the parameters in the url. There is no way to pass parameters without passing them!
        URLs of the form: http://www.local-angle.com/album/index.cgi?topn=40 Are equivelent to the request generated by:
        <form action="http://www.local-angle.com/album/index.cgi" method="get" +> <input type="hidden" name="topn" value="40"> <input type="submit">

        Because of the properties of an anchor (<a>), it will always do a GET, as it has no form information to POST.

        The solutions to your problem are:

        1. Live with it
        2. Use forms, instead of anchors

        --
        RatArsed

Re: funky URLs
by John M. Dlugosz (Monsignor) on Jun 30, 2001 at 00:34 UTC
    Look at the difference between GET and POST for forms. GET uses the args in the URL, and POST sends the data via standard input to the script.

    — John

Re: funky URLs
by Maclir (Curate) on Jun 30, 2001 at 00:35 UTC

    If you are using the standard CGI processing module, CGI.pm, there are building methods to extract the URL in various formats, plus have the variables returned to your program.

    If you are not using CGI.pm, then you should be.

    Update: Oops - I didn't read the real question close enough. (bonks himself over the head and retires for a coffee)