Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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/location.pl?URL=$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:

$referrer=$ENV{'HTTP_REFERER'};
and that's that. No CGI.pm, 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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (10)
    As of 2014-09-19 21:30 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (147 votes), past polls