Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

How can I pass the URL of the page I am on?

( #36008=categorized question: print w/ replies, xml ) Need Help??
Contributed by Anonymous Monk on Oct 10, 2000 at 02:02 UTC
Q&A  > CGI programming

Answer: How can I pass the URL of the page I am on?
contributed by AgentM

Assuming you wish to pass the URL from a CGI script to the next page:

use CGI; ... $query->hidden('URL',$query->self_url); ...
Assuming you wish to pass the URL from the web page to the CGI.
  1. on your page create a hidden field that contains the pertinent information
  2. use the param() function in CGI to retrieve the variable and voila!
In the future, please be more specific in your question and post them to Seekers of Perl Wisdom instead.
Answer: How can I pass the URL of the page I am on?
contributed by cianoz

...and if you can't use forms then:

use URI::Escape; my $url = $query->self_url; $url = uri_escape($url); # or $query->url; it depends.. print qq{<a href="/path/to/new/$url">new location</a>} +;
Answer: How can I pass the URL of the page I am on?
contributed by Trimbach

... and if you want to find out the URL of the webpage that triggered your CGI in the first all you have to do is:

and that's that. No, no forms, no nothin'.

Please (register and) log in if you wish to add an answer

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (9)
    As of 2016-06-24 22:25 GMT
    Find Nodes?
      Voting Booth?
      My preferred method of making French fries (chips) is in a ...

      Results (322 votes). Check out past polls.