getting referring page

This isn't REALLY a Perl question.  More of a 'script-calling' question.  I wrote a perl script that gets the $ENV{'HTTP_REFERER'} of the referring page and writes it to a database.  It's to keep track of where my visitors are coming from.  It works fine and dandy as I have written it.  Now the problem is that I'm not sure how to call my script from my web page.  I tried to put it in a cheezie tag like so: <img src="/cgi-bin/track.pl" width=0 height=0 border=0>.

The problem is that the script uses the page (my page) that the <img...> tag is on as the referer and not the page that the user came from in the first place.

To clarify:
Let's say my page is http://mysite.com/mypage.html  and the user comes from http://xyzsite.com/theirpage.html.  The referer variable in my script that I call from mypage.html should contain the string 'http://xyzsite.com/theirpage.html'.  How can I call my script from mypage.html so that it tricks my script into considering xyzsite.com's page as the referring page??
LVL 1
GorGor1Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
yorenConnect With a Mentor Commented:
You can't do that directly. I'd suggest making mypage.html a dynamic page (CGI, etc.). You can then set a cookie (or dynamically add a CGI script parameter) equal to the referring site. Your script can then reference the cookie or CGI parameter instead of HTTP_REFERRER.
0
 
jhurstCommented:
I partially aggree with the previos and differ too.  I would avoid the cookie if you can.

When I have needed to do this or other things, such as show different pages depending on the browser being used, what I have done is ensured that there is no page:

http://www.mySite.com/myPage.html

Then I have created an error404 script that will be invoked when any non-found happens.  In this page I check and see if the requested page was myPage.html.  If it was, then I do the logging, or whatever else and then transmit the page, which us now stored as something like myPage.html.x.
0
 
rrbfCommented:
Your solution isn't that 'cheezie'. many do use it.
The more classical solution is to setup .html
as an SSI (server side include) to include the script with an <!--#include ... -->
if html extensions are not SSI enabled and you want to stick
to a .html rather than a .cgi or .pl or .shtml
you can do that in .htaccess with this line:
AddHandler server-parsed .shtml .html

check http://httpd.apache.org/docs/mod/mod_include.html
ssi are installed and enabled by default in most apache installs.
0
 
GorGor1Author Commented:
I can't use .htaccess because I'm not using apache.  I'm using IIS in win2k.  I found a solution and I'm working with it now.  I'll post the solution and accept an answer when I'm done.  Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.