Here is my problem. I have developed site where user
will be able to capture URL of pages he is visiting and save the URL and some additional information in a
database. I have developed script that generates a form. This form contains several text fields, one of them is URL adedress of the page user is visiting.
This script resides on my server and is accessable from Favorites or Links in IE, or Bookmarks in Netscape. I would like to capture URL, save it in a variable, let say $url, and then use this variable to
set a value for the text field in the form.
Welcome to WebmasterWorld [webmasterworld.com]!
This works on Apache to get the requested URI:
$uri = "$ENV{'REQUEST_URI'}";
take a look here
[perl.about.com...]
I just got done working on a PERL 'rename file' problem, and support for PERL across many systems is not at all consistent. You should provide a fallback in your code in case that variable returns null - You may have to ask the user to cut-n-paste from the address bar in that case, or use client-side scripting to fill it in.
Jim
Cut-and-paste doesn't work for me because my site should work for dumm users. Client-side script may
help, but I want to avoid any installations on user's
computer for the same reason. This is why I decided
to create a bookmarklet (a link that runs a program
that resides on my server and runs on the browser).
It first should grab url and then create a form
with this URL in, then user adds some other information reqired and on submit all data are sent to database. I tried to use JavaScript: it works with
new blank window, but doesn't with the form stored on
the server because of JavaScript self-domain security issue. I'll try what you are suggesting and will let you know. So, I'm trying $uri = $ENV(REQUEST_URI);
right?
Many thanks and regards, Roman
I have wrote a small script that checks all environment variables keys and values on my ISP's
server and I cannot find REQUEST_URI and DOCUMENT_URI there.
Here is the script:
#!c:\perl\bin
#env.pl
print "Content-type: text/plain\n\n";
while (($key, $value)=each(%ENV)){
print "$key = $value\n"; }
What does it mean?
Roman
I have solved the problem, using QUERY_STRING variable
that captures value passed to the CGI script.
I have developed small javascript, see below:
javascript: void(open('http://www...../captureurl.pl?'+location.href; new window properties go here))
At the top of captureurl.pl file I put
my $url = $ENV{QUERY_SCRIOPT};
Thanks for your help.
Roman