User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,422 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,345 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting

Detect User Details?

Join Date: Sep 2005
Posts: 689
Reputation: digital-ether has a spectacular aura about digital-ether has a spectacular aura about 
Rep Power: 6
Solved Threads: 41
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Practically a Master Poster

Help Re: Detect User Details?

  #2  
Nov 28th, 2007
If you use a <script> tag then you will get the URL/page where the <script> tag is in as the referer.

example: if index.php has:

<script src="spy.php">

Then you'll always get index.php as the referer. This is because the user was on index.php when the HTTP request for spy.php was made.

If you want to get the site the user came from, then you have to save their referer in index.php. You can either append this data to your script src, or save it directly.

eg:

in index.php use:
<script src="spy.php?referer=<?php echo $_SERVER["HTTP_REFERER"]; ?>"></script>

Then in referer.php retrieve the site the user came from via:

$referer = $_GET['referer'];

Or you can just include spy.php in your PHP file:

include('spy.php');

This reduces the HTTP requests/bandwidth to your server.

One thing I noticed is the your spy.php gives non-js output. This will cause any JavaScript debuggers on the HTTP Client (users browsers) to display error messages.
What you want to do is give out a header('Content-Type: text/js'); and also reduce output to a format such as JSON or just JS. If viewed directly, you can still read the output and thus do your own debugging...
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
All times are GMT -4. The time now is 2:09 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC