Solved

getting referring page

Posted on 2002-06-01
4
372 Views
Last Modified: 2012-06-27
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??
0
Comment
Question by:GorGor1
4 Comments
 
LVL 7

Accepted Solution

by:
yoren earned 50 total points
ID: 7049338
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
 
LVL 8

Expert Comment

by:jhurst
ID: 7065414
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
 

Expert Comment

by:rrbf
ID: 7069993
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
 
LVL 1

Author Comment

by:GorGor1
ID: 7070145
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl Sort Question 4 129
Rename file based on contents in the file? 3 80
crawling gofundme 4 119
Extract data from span tag 1 91
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now