Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

getting referring page

Posted on 2002-06-01
4
Medium Priority
?
406 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 7

Accepted Solution

by:
yoren earned 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Six Sigma Control Plans

670 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