6 Replies - 7743 Views - Last Post: 05 December 2008 - 04:30 PM Rate Topic: -----

#1 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 43
  • View blog
  • Posts: 903
  • Joined: 08-August 08

finding out where the user came from

Posted 05 December 2008 - 12:13 PM

is there a way of finding out where a user came from, eg say they clicked on a link from google how would you be able to tell they came from a google link not just by typing in a url or something ?

any help greatly appreciated


just googled it and found it is something to do with $http_referer. but it doest say how to use it, could someone explain please?

This post has been edited by ghqwerty: 05 December 2008 - 12:15 PM

Is This A Good Question/Topic? 0
  • +

Replies To: finding out where the user came from

#2 BenignDesign  Icon User is offline

  • holy shitin shishkebobs
  • member icon




Reputation: 6233
  • View blog
  • Posts: 10,782
  • Joined: 28-September 07

Re: finding out where the user came from

Posted 05 December 2008 - 12:19 PM

http://www.electrict...ferer-variable/

That should get you started.
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: finding out where the user came from

Posted 05 December 2008 - 12:20 PM

This will show you where the user came from

echo $_SERVER['HTTP_REFERER']



I cant be 100% positive that this cannot be hidden by ping through a proxy server though
Was This Post Helpful? 0
  • +
  • -

#4 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 43
  • View blog
  • Posts: 903
  • Joined: 08-August 08

Re: finding out where the user came from

Posted 05 December 2008 - 12:26 PM

thankyou, i just found that on google too, lol

so, jusst been looking on google and can't seem to find out how i would 'split' a url from that to determine wether they came from within my site or not.


what im trying to do is to get my login so that if the user comes from my own site, say the try to go to www.blisswars.net23.net/extortion.php then they will get redirected to my login www.blisswars.net23.net/default.php then they get redirected to the page they were on.

so, i need to be able to test somehow if they came from an internal page, i thought about splitting the last bit so that if the first bit of the url was 'www.blisswars.net23.net' then it would find the last bit and add it on for a redirect and if it werent it would simply go to the home page
Was This Post Helpful? 0
  • +
  • -

#5 BenignDesign  Icon User is offline

  • holy shitin shishkebobs
  • member icon




Reputation: 6233
  • View blog
  • Posts: 10,782
  • Joined: 28-September 07

Re: finding out where the user came from

Posted 05 December 2008 - 12:42 PM

Never tried this myself, but a good place to start might be by looking into the split() function.
Was This Post Helpful? 0
  • +
  • -

#6 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 43
  • View blog
  • Posts: 903
  • Joined: 08-August 08

Re: finding out where the user came from

Posted 05 December 2008 - 03:13 PM

i looked into this but wouldnt know how to use it properly, if i did split using / as the 'splitter' then it would split at http:// not .net/blah like i want it to :S any ideas ???
Was This Post Helpful? 0
  • +
  • -

#7 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5929
  • View blog
  • Posts: 12,851
  • Joined: 16-October 07

Re: finding out where the user came from

Posted 05 December 2008 - 04:30 PM

View Postghqwerty, on 5 Dec, 2008 - 01:26 PM, said:

what im trying to do is to get my login so that if the user comes from my own site, say the try to go to www.blisswars.net23.net/extortion.php then they will get redirected to my login www.blisswars.net23.net/default.php then they get redirected to the page they were on.


I'd recommend looking into PHP sessions. When the user asks for any page, check to see if they've logged in. If they haven't, make a note of where you are (in the session), then send them where need to go.

Here's a simple bounce:

a.php:
<?php
session_start(); 
if (!isset($_SESSION['front_door'])) {
	$_SESSION['front_door'] = 1;
}
?>
<html><h1>Welcome to the Site</h1>
<p><a href="b.php">Visit here</a></p>
</html>



b.php:
<?php
session_start(); 
if (!isset($_SESSION['front_door'])) {
	header( 'Location: a.php' ) ;
	die();
}
?>
<html><h1>Here there be tigers</h1></html>



If you should ask for b.php before a.php, you'll be send to the front page. Normally nothing will be set until they login, but hopefully this will give some idea of how it works.
Was This Post Helpful? 1

Page 1 of 1